Issue with strategy tester and large period moving averages

 

I'm unable to figure out why MT4 strategy tester is having issues properly realizing moving averages based on high periods (such as 1000 or more bars). I've tried both iMA as well as iCustom (referencing the provided Moving Averages function and the printed results (just printing the MA price for a specific bar to the journal) differs than what I see in the Data Window for the same bar for the same MA. At the 1000 bars period the difference can be a few pips and the difference grows as the period increases. At 1400 bars the difference (between iMA/iCustom in the EA vs what's on screen) is over 10 pips.


The difference is lessened after a few days into the backtest results (on M5). So I figure this means that the strategy tester isn't recognizing the correct MA levels until the prerequisite number of bars passes (even for EMA MA method). Is this correct and is there any workaround for this? I need for my backtests to be accurate and need to come up with a solution to this problem.


I guess I could insert a param for testing purposes for the month number to test and then set the start time period to a week prior to the start of the month. Is that what others do to overcome this issue? 

Thanks for any help.

 
billworld:

I'm unable to figure out why MT4 strategy tester is having issues properly realizing moving averages based on high periods (such as 1000 or more bars). I've tried both iMA as well as iCustom (referencing the provided Moving Averages function and the printed results (just printing the MA price for a specific bar to the journal) differs than what I see in the Data Window for the same bar for the same MA. At the 1000 bars period the difference can be a few pips and the difference grows as the period increases. At 1400 bars the difference (between iMA/iCustom in the EA vs what's on screen) is over 10 pips.

There are limited bars available prior to the start date in the Strategy Tester,  so start the test earlier and wait for a few hundred bars to pass. . . . then allow your EA to run.  This way you will have more bars to the left. 
 

If you don't specify a start date/time you get the earliest history + 100 bars.

If you specify a start date/time you get the 1000 bars if you have that much stored history

Your EA should check the number of bars available vs MA. You need SMA(p): p bars and EMA(p) 3.45(p+1) bars.

Reason: