MT4 MA on chart does not match iMA

 
Put this custom indicator on a MT4 chart - any symbol, say H4 timeframe. Just make sure the symbol is moving - not in consolidation.

#property indicator_chart_window
int start()   {
   double ma = iMA(NULL, 0, 2, 0, MODE_SMA, MODE_CLOSE, 0);
   Comment("ma = ", ma);
   return(0);
   }




Now add a 2 period simple moving average of the close to your chart. Open the DataWindow (Ctrl-D) and move your cursor to the last bar and compare the MA(2) value of the last bar from the data window with the "ma=" in the upper lefthand corner of the chart.

I think MA value on the last bar on the chart should match the MA value posted by the expert in the Comment call. Is this a bug or am I missing something?

 
Why MODE_CLOSE ? May be PRICE_CLOSE ? Read help before, RFTM
Reason: