What am I missing?

 

Trading manually works well for me, however in trying to automate I am running into an issue. If I use the simple Bands indicator and convert the MA calc to


MovingBuffer[i]=iMA(NULL,15,BandsPeriod,BandsShift,MODE_SMA,PRICE_CLOSE,i);

I can not seem to get similar numbers if I attach it to a 5 min and a 15 min chart. Am I confused about the what the second parameter of timeframe should be doing? Do I have to also extend the BandsPeriod?

Any hints would be much appreciated.

Thanks

 

You shouldn't have to expand the BandsPeriod -

The syntax is this:

double iMA( string symbol, int timeframe, int period, int ma_shift, int ma_method, int applied_price, int shift)

Where "period" refers to the number of bars averaged in the "timeframe" specified.

I get better results when I use the timeframe syntax here: https://docs.mql4.com/constants/timeframes

So instead of 15, try PERIOD_M15

 
joetrader:

I get better results when I use the timeframe syntax here: https://docs.mql4.com/constants/timeframes

So instead of 15, try PERIOD_M15

Joe, all constants are replaced by the preprosessor with their value before compilation. The result will be identical. If u got different results, it's due to some other factor. Using constants just makes the code more readable.