Exponential Moving Average Error

 

Help please.

I have calculated the average price using an exponential moving average on 5 min time frame. Where sym is the chart symbol because I am trading multiple charts with an EA attached to a chart. See below.

map = iMA(sym,5,3,0,MODE_EMA,PRICE_MEDIAN,0);

The values are different from the values shown by MT4 EMA for the same period and time frame. For some symbols, they are close. The difference is more on USDJPY. Why is that? 

 
The parameters used must be different.
 

No. The same parameters. See below.



 
map = iMA(sym,5,3,0,MODE_EMA,PRICE_MEDIAN,0);

You are checking the current bar which is constantly changing.

By the time you get the value and then check against the indicator, the value may have changed.

Reason: