Download MetaTrader 5

iMA function get wrong value in EA

To add comments, please log in or register
remyvi
6
remyvi  

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.


Ian Flanagan
549
Ian Flanagan  

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.

Keith Watford
Moderator
10070
Keith Watford  
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
To add comments, please log in or register