Author: Copyright � 2008, MetaQuotes Software Corp.
GA-ind

This custom trading indicator is designed to provide visual analysis of market momentum by calculating two primary data points: the MACD value and its corresponding Signal line. It operates in a separate window beneath your main price chart, allowing for a clear view of trend shifts without cluttering the actual price candles.

How the Logic Works

The tool functions by looking at the relationship between two different types of moving averages to determine market "speed" and "direction." Here is the step-by-step breakdown of its logic:

1. The Primary Calculation (MACD Value) The indicator begins by identifying two different price trends simultaneously: a "Fast" trend and a "Slow" trend. It calculates these using an Exponential Moving Average (EMA), which reacts more quickly to recent price changes than standard averages.

  • Instead of subtracting these two values from one another (which is the standard industry practice for MACD), this specific script adds them together. This creates a unique cumulative value represented as blue arrows on your screen, highlighting the combined weight of the short-term and long-term price movements.

2. The Smoothing Process (Signal Line) To make the data easier to read and to filter out "market noise" or minor fluctuations, the script performs a second calculation. It takes the cumulative values generated in the first step and applies a Simple Moving Average (SMA) to them.

  • This results in the Signal Line, displayed as a red line on your chart. This line acts as a smoothed-out version of the primary data, helping traders identify the broader flow of the market trend.

3. User Customization The logic is built to be flexible, allowing you to adjust three key "sensitivity" settings:

  • FastEMA: Determines how quickly the indicator reacts to immediate price changes.
  • SlowEMA: Determines the timeframe for the long-term trend analysis.
  • SignalSMA: Controls how much smoothing is applied to the final Signal Line.

Summary of Visual Output

When you apply this indicator, you will see a dedicated window where the Blue Arrows represent the raw combined momentum of the market's fast and slow trends. The Red Line follows these movements, providing a smoothed path that helps you distinguish between temporary price spikes and sustained directional shifts.

Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
GA-ind
//+------------------------------------------------------------------+
//|                                                       GA-ind.mq4 |
//|                      Copyright © 2008, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 2
#property  indicator_color1  Blue
#property  indicator_color2  Red
#property  indicator_width1  2
//---- indicator parameters
extern int FastEMA=12;
extern int SlowEMA=26;
extern int SignalSMA=9;
//---- indicator buffers
double     MacdBuffer[];
double     SignalBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- drawing settings
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexDrawBegin(1,SignalSMA);
   IndicatorDigits(Digits+1);
//---- indicator buffers mapping
   SetIndexBuffer(0,MacdBuffer);
   SetIndexBuffer(1,SignalBuffer);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("MACD("+FastEMA+","+SlowEMA+","+SignalSMA+")");
   SetIndexLabel(0,"MACD");
   SetIndexLabel(1,"Signal");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence                           |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- macd counted in the 1-st buffer
   for(int i=0; i<limit; i++)
      MacdBuffer[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)+iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
//---- signal line counted in the 2-nd buffer
   for(i=0; i<limit; i++)
      SignalBuffer[i]=iMAOnArray(MacdBuffer,Bars,SignalSMA,0,MODE_SMA,i);
//---- done
   return(0);
  }
//+------------------------------------------------------------------+

Comments