MTF mismatch

 
I usually backtest my EAs in Open Prices M1, simply because it is way too slow otherwise

I came up with a bug though.
I had a problem : my orders were opening at an hourly level, not a M1 level (despite using M1 OP in the strategy tester settings)
so I pinpointed down the error to an ATR Handle :  
If I changed the ATR TF, the whole tester starts using that timeFrame to open and close orders but only at the opening of an H1 candle.

and most bizzarely:
if I write :

atrHandle[i] = iATR(sym, PERIOD_H1, 14);
atrHandle2[i] = iATR(sym, PERIOD_M1, 14);
I got an error :

2026.09.18 16:36:27.707 CADCHF,M1: wrong timeframe request in Open Prices testing mode

but if I put atrHandle2 FIRST :

atrHandle2[i] = iATR(sym, PERIOD_M1, 14);
atrHandle[i] = iATR(sym, PERIOD_H1, 14);
then I got no error.
and if, in this configuration, I never even USE atrHandle2, it backtests with M1 precision, not H1....
so it seems that in OP M1 tester mode, the first requested timeFrame will be the timeFrame used for the backtester ?

is that strange ?!!! i don't understand
Jef
 

also if I use NULL instead of symbol name 'sym' it backtests in H1, not M1 anymore

so it seems related to the multipair somehow

atrHandle2[i] = iATR(NULL, PERIOD_M1, 14);
atrHandle[i] = iATR(sym, PERIOD_H1, 14);
 
Jean Francois Le Bas:
I usually backtest my EAs in Open Prices M1, simply because it is way too slow otherwise

I came up with a bug though.
I had a problem : my orders were opening at an hourly level, not a M1 level (despite using M1 OP in the strategy tester settings)
so I pinpointed down the error to an ATR Handle :  
If I changed the ATR TF, the whole tester starts using that timeFrame to open and close orders but only at the opening of an H1 candle.

and most bizzarely:
if I write :

I got an error :

2026.09.18 16:36:27.707 CADCHF,M1: wrong timeframe request in Open Prices testing mode

but if I put atrHandle2 FIRST :

then I got no error

It makes sense, to me at least, that the Tester having read the higher resolution M1 data first, can readily synchronize H1 data based on M1 data. In contrast thereto, synchronizing M1 data based on lower resolution H1 data─not so much.

Jean Francois Le Bas:
and if, in this configuration, I never even USE atrHandle2, it backtests with M1 precision, not H1....
so it seems that in OP M1 tester mode, the first requested timeFrame will be the timeFrame used for the backtester ?

That would seem to follow. In that case, you're simply not calling data from a 2nd timeframe.

Jean Francois Le Bas #:

also if I use NULL instead of symbol name 'sym' it backtests in H1, not M1 anymore

so it seems related to the multipair somehow

You should never use NULL without a specific reason for doing so. Access to ENUM_TIMEFRAMES is lost when you do that.

 
Ryan L Johnson #:

It makes sense, to me at least, that the Tester having read the higher resolution M1 data first, can readily synchronize H1 data based on M1 data. In contrast thereto, synchronizing M1 data based on lower resolution H1 data─not so much.

That would seem to follow. In that case, you're simply not calling data from a 2nd timeframe.

You should never use NULL without a specific reason for doing so. Access to ENUM_TIMEFRAMES is lost when you do that.

but the tester OpenPrice timeframe depends on the first request I make in the code, not the TF I selected ? I don't understand


and I never try to request M1 data on a H1 timeframe. I'm ALWAYS on a M1 timeframe, I don't change the timeframe of the strategy tester, yet the trading changes to H1 under certain conditions

 
No code to reproduce leads to guess or lack of answer.
 
Alain Verleyen #:
No code to reproduce leads to guess or lack of answer.
i'll make a code thanks
 
Jean Francois Le Bas #:
i'll make a code thanks
No need for code
  • The tested Expert Advisor cannot access data of a timeframe below the testing/optimization timeframe. For example, if your run testing/optimization on the H1 period, you can access data of H2, H3, H4 etc., but not M30, M20, M10 etc. In addition, the higher timeframes that are accessed must be multiple of the testing timeframe. For example, if you run testing on M20, you cannot access data of M30, but it is possible to access H1. These limitations are connected with the impossibility to obtain data of lower or non-multiple timeframes out of the bars generated during testing/optimization.
  • Limitations on accessing data of other timeframes also apply to other symbols whose data are used by the Expert Advisor. In this case the limitation for each symbol depends on the first timeframe accessed during testing/optimization. Suppose, during testing on EURUSD H1, an Expert Advisor accesses data of GBPUSD M20. In this case the Expert Advisor will be able to further use data of EURUSD H1, H2, etc., as well as GBPUSD M20, H1, H2 etc.
https://www.metatrader5.com/en/terminal/help/algotrading/tick_generation