iMA function get wrong value in EA

 

I'm building an EA trading in 15 minutes timeframe,However, I want to check the trend in daily MA, so I run the following code to determine the trend.

double ma=iMA(NULL,PERIOD_D1,2,0,MODE_SMA,PRICE_CLOSE,0);

Also, I add a MA indicator in daily chart. However, the value of ma is not equal the value in chart, for example, 2012.1.29, the ma of EURUSD in indicator is 1.3174, the value of EA ma is 1.3096. I don't know why, please help me to fix it.


 

you can get the code used in the MA indicator (google it) and see the difference

seems a bit strange you are finding the trend by averaging over only 2 bars.

 
trendflowto:

I'm building an EA trading in 15 minutes timeframe,However, I want to check the trend in daily MA, so I run the following code to determine the trend.

double ma=iMA(NULL,PERIOD_D1,2,0,MODE_SMA,PRICE_CLOSE,0);

Also, I add a MA indicator in daily chart. However, the value of ma is not equal the value in chart, for example, 2012.1.29, the ma of EURUSD in indicator is 1.3174, the value of EA ma is 1.3096. I don't know why, please help me to fix it.



Probably because the settings for the iMA in the EA are not the same as the MA on the chart