Strategy Tester Period: EA Multiple TimeFrame

 
Hi,
My EA is using custom made indicators (e.g. Keltner channel from https://www.mql5.com/en/code/8445). It is looking on multiple timeframes 
using iCustom where the second parameter is set to different timeframes. 

In the strategy tester, if I select the Period to be H1 and press the start button my EA works fine (if all the custom indicators are set to use Period_H1). 
If I select Period to be M30 in the strategy tester and then press start the tester does not work. Note that all the timeframes are still set to Period_H1 in the EA file. 
Error is: an infinite loop of Ketlner channel being removed in the journal tab.

The Period in the strategy tester does not make much sense for my EA because I have many timeframes.

My Attempt:
I found that the Keltner channel has the following line and the second parameter of iMA is set to 0 i.e. the current chart.
I changed this line from the keltner channel mq4:
middle[x] = iMA(NULL, 0, period, 0, MODE_SMA, PRICE_TYPICAL, x);
to
middle[x] = iMA(NULL, PERIODSET, period, 0, MODE_SMA, PRICE_TYPICAL, x);

where PERIODSET is defined to be extern int PERIODSET = "some period". And when I call iCustom I pass this period like: 

iCustom(Symbol(), PERIOD_H1, KeltnerPeriod, PERIOD_H1, 0, 1);

where the parameter after  KeltnerPeriod is is for PERIODSET

It did not work; same error as above. Does anyone know if this testing is possible?

Thx! 

PS:
In https://forum.mql4.com/53560 
Raptor said that we can test on multiple timeframes

WHRoeder said that we can do it if we do the following:

datetime when = Time[i];                            // Chart
int      iM5 = iBarShift(NULL, 0, when);            // M5
double   m5value = iHigh(Symbol(), PERIOD_M5, iM5); // M5
ExtCurrM5H[i] = m5value;  

But that will not work in iCustom functions


MT4 Build:1035
 
hyiou: I changed this line from the keltner channel mq4:
middle[x] = iMA(NULL, 0, period, 0, MODE_SMA, PRICE_TYPICAL, x);
to
middle[x] = iMA(NULL, PERIODSET, period, 0, MODE_SMA, PRICE_TYPICAL, x);

Don't mix apples and oranges. X indexes the current timeframe bars. You can't use it on other timeframes. Would you want middle[1] to be yesterdays MA of D1 chart and middle[7] to be last weeks?

int iPS = iBarShift(NULL, PERIODSET, Time[x])
middle[x] = iMA(NULL, PERIODSET, period, 0, MODE_SMA, PRICE_TYPICAL, iPS);
 
WHRoeder:

Don't mix apples and oranges. X indexes the current timeframe bars. You can't use it on other timeframes. Would you want middle[1] to be yesterdays MA of D1 chart and middle[7] to be last weeks?

Thanks but I am not sure after testing the following: 

1/ I have verified:

Print(iClose(Symbol(), PERIOD_D1, 1)); 

on a 1hr chart i.e. put the above in an ea and then run strategy tester with Period: 1hr.

The time given in the journal tab is indeed correct (time of close of the previous day). But according to what you said the shift of "1" in the above print statement should refer to the current chart which is of Period 1hr. This did not happen.

2/The second thing is that when I run my multiple timeframe ea on a live trading it works (not sure if it always work) even though the chart I opened is a 1hr one

Reason: