top of page

Page 1 of 3

MQL4 Reference / Technical Indicators / iMACD


Calculates the Moving Averages Convergence/Divergence indicator and returns its value.

double  iMACD(
  string       symbol,           // symbol
  int          timeframe,        // timeframe
  int          fast_ema_period,  // Fast EMA period
  int          slow_ema_period,  // Slow EMA period
  int          signal_period,    // Signal line period
  int          applied_price,    // applied price
  int          mode,             // line index
  int          shift             // shift



         [in]  Symbol name on the data of which the indicator will be calculated. NULL means the current symbol.


         [in]  Timeframe. It can be any of ENUM_TIMEFRAMES enumeration values. 0 means the current chart timeframe.


         [in]  Fast EMA averaging period.


         [in]  Slow EMA averaging period.


         [in]  Signal line averaging period.


         [in]  Applied price. It can be any of ENUM_APPLIED_PRICE enumeration values.


         [in]  Indicator line index. It can be one of the Indicators line identifiers enumeration values (0-MODE_MAIN, 1-MODE_SIGNAL).


         [in]  Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago).

Returned value

         Numerical value of the Moving Average of Oscillator indicator.


In some systems it is called MACD Histogram and plotted as two lines. In MetaTrader 4 client terminal MACD is plotted as histogram.


 if(iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0)>iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0)) return(0);

bottom of page