MT5 backtest Set current market block
-
Hi,
I'm trying to make a single EA work on multi symbols in backtest mode with MT5.I'm using the Set "Current market" block but the results are unexpected.
In this example, I want to print in the journal the values of the ATR day by day for 28 pairs.
https://fxdreema.com/shared/we46piTge
However, at the beginning of the execution there is an issue:
I'm running from 2020/01/01.
In the screenshot below, on the 2020/01/02 AUDCAD, AUDCHF, AUDJPY, AUDUSD are printed.
But then the EA continues to the 2020/01/03 and prints from CADCHF up to EURAUD only and then skip again to 2020/01/06 without printing the remaining other pairs.
Then after awhile, all the pairs are printed correctly:

Any idea what is causing this ?
Thank you for your help.
Valentin -
I'm not a programmer, but are you sure the formula in the 'log message' block is correct?
-
@vhager maybe some pairs dont have data from 2020/01/01, their history starts some time later?
@l-andorrà the formula is correct, otherwise there wouldn't be any prints at all
-
Thank you for your replies.
Yes there is data for those pairs, I can go all the way back to the years 2000s
It seems the EA is struggling when the tester is still synchronizing all the symbols..If it is a bug, how to fix it ?
-
@vhager you are using ATR and some other indicators, they need some history data before 2020/01/01 in order to get the indicator value for 2020/01/01.
For single symbol backtests, Metatester is smart enough to compensate for the indicator history requirement, but the additional symbols might not load the data into tester (even though you have the data on your hard drive).Try running the loop in the "On Init" tab, getting the indicator values there, so the EA has a chance to preload the necessary history data. Maybe it works, maybe doesnt
-
@roar Thanks for your help. I copied the "set current market block" and all the blocks under, in the init tab, but it gives the same result.
Some pairs are still loaded successfully so I'm not sure it's the a data history issue.It seems more like an index error in the loop of the "set current market block".
I tried to add the a "job done" message at the exit of the block:

But the message "job done" is displayed for the first time on the 2020/01/10

After that it is displayed correctly.
-
I also tried to start in 2022/02/01 and the result is the same, until the 2022/02/09 the results are not correct