EA with multiple time frames

 
Hello ,
1- If there's an EA with multiple time frames , Does it make any difference which time frame I attached it to ?

2- Something very strange happens with this EA , it depend on 3 conditions and every condition from specific time frame , it's quite strict in backtesting but in real it always has to miss a condition , For example : I attached it to 1H , it will ignore 30M or 15 M condition but If I attached it to 30 M it will ignore 15 M or 1H conditions ,Does it ever happen to anyone ?
The Code pulls the data from the mentioned time frame there no such thing in the code like I will pull the data from current time frame and Don't forget that This never happens in the backtesting ( it's very strict there )

Thanks 
 
Saadan Elfayed:
Hello ,
1- If there's an EA with multiple time frames , Does it make any difference which time frame I attached it to ?

Depends on your code. If you use things like PERIOD_CURRENT or you don't use iBarShift to get the correct index, yes it will make a difference.
 
Nope I don't use anything like that , thanks for replying , Hope anyone can figure out the second question
 
Mohamed Mohamed:
Nope I don't use anything like that , thanks for replying, Hope anyone can figure out the second question 


Not possible without seeing the code I'm afraid.

It is like telling a mechanic over the phone that your car makes a funny noise in 3rd gear.

 
Mohamed Mohamed:
Hello ,
1- If there's an EA with multiple time frames , Does it make any difference which time frame I attached it to ?

2- Something very strange happens with this EA , it depend on 3 conditions and every condition from specific time frame , it's quite strict in backtesting but in real it always has to miss a condition , For example : I attached it to 1H , it will ignore 30M or 15 M condition but If I attached it to 30 M it will ignore 15 M or 1H conditions ,Does it ever happen to anyone ?
The Code pulls the data from the mentioned time frame there no such thing in the code like I will pull the data from current time frame and Don't forget that This never happens in the backtesting ( it's very strict there )

Thanks 

In backtesting, I thought, it only uses current timeframe because data from other timeframes will not open. When on real quotes, it will take the quote from those 3 timeframes.
 
Irwan Adnan: In backtesting, I thought, it only uses current timeframe because data from other timeframes will not open.
Only irregular TFs (Weekly, Monthly) are not supported. 'Testing Features and Limits in MetaTrader 4' - MQL4 Articles
 
whroeder1:
Only irregular TFs (Weekly, Monthly) are not supported. 'Testing Features and Limits in MetaTrader 4' - MQL4 Articles

I could be wrong, but from my experience, when I was backtesting my custom indicator/EA which include some timeframes (eg 5, 15, 30, H1, H4, D1) using same standard indicator with same parameters (except for that timeframe parameter), I got on my chart there is only a current timeframe value was changed while value of other timeframes were not.
 

Contrary to the documentation, I have found the strategy tester can retrieve values from irregular timeframes:

(M18 is an offline chart, EA running on the H1)

void OnTick()
  {
   static datetime lastbar=0;
   if(Time[0]!=lastbar)
     {
      Print(iHigh(_Symbol,18,0));    
      lastbar=Time[0];
     }
  }
0	08:20:13.021	2017.04.05 14:00:00  Test Ger30Sb617,H1: 0.0
0	08:20:13.035	2017.04.05 15:00:00  Test Ger30Sb617,H1: 0.0
0	08:20:13.047	2017.04.05 16:00:00  Test Ger30Sb617,H1: 0.0
0	08:20:13.058	2017.04.05 17:00:00  Test Ger30Sb617,H1: 0.0
0	08:20:13.072	2017.04.05 18:00:00  Test Ger30Sb617,H1: 0.0
0	08:20:13.080	2017.04.05 19:00:00  Test Ger30Sb617,H1: 0.0
0	08:20:13.087	2017.04.05 20:00:00  Test Ger30Sb617,H1: 0.0
0	08:20:13.098	2017.04.05 21:00:00  Test Ger30Sb617,H1: 0.0
0	08:20:13.116	2017.04.06 08:00:00  Test Ger30Sb617,H1: 12163.0
0	08:20:13.127	2017.04.06 09:00:00  Test Ger30Sb617,H1: 12180.0
0	08:20:13.144	2017.04.06 10:00:00  Test Ger30Sb617,H1: 12145.5
0	08:20:13.159	2017.04.06 11:00:00  Test Ger30Sb617,H1: 12189.0
0	08:20:13.166	2017.04.06 12:00:00  Test Ger30Sb617,H1: 12187.5
0	08:20:13.177	2017.04.06 13:00:00  Test Ger30Sb617,H1: 12216.0
0	08:20:13.188	2017.04.06 14:00:00  Test Ger30Sb617,H1: 12232.0
0	08:20:13.198	2017.04.06 15:00:00  Test Ger30Sb617,H1: 12227.0
0	08:20:13.212	2017.04.06 16:00:00  Test Ger30Sb617,H1: 12240.5
0	08:20:13.230	2017.04.06 17:00:00  Test Ger30Sb617,H1: 12248.5
0	08:20:13.247	2017.04.06 18:00:00  Test Ger30Sb617,H1: 12246.5
0	08:20:13.255	2017.04.06 19:00:00  Test Ger30Sb617,H1: 12234.5
0	08:20:13.262	2017.04.06 20:00:00  Test Ger30Sb617,H1: 12245.0
0	08:20:13.273	2017.04.06 21:00:00  Test Ger30Sb617,H1: 12226.0
0	08:20:13.284	2017.04.07 08:00:00  Test Ger30Sb617,H1: 12211.5
0	08:20:13.298	2017.04.07 09:00:00  Test Ger30Sb617,H1: 12197.0
0	08:20:13.313	2017.04.07 10:00:00  Test Ger30Sb617,H1: 12194.5
0	08:20:13.324	2017.04.07 11:00:00  Test Ger30Sb617,H1: 12184.0
0	08:20:13.334	2017.04.07 12:00:00  Test Ger30Sb617,H1: 12199.5
0	08:20:13.345	2017.04.07 13:00:00  Test Ger30Sb617,H1: 12203.5
0	08:20:13.352	2017.04.07 14:00:00  Test Ger30Sb617,H1: 12208.0
0	08:20:13.366	2017.04.07 15:00:00  Test Ger30Sb617,H1: 12197.5
0	08:20:13.388	2017.04.07 16:00:00  Test Ger30Sb617,H1: 12204.5
0	08:20:13.399	2017.04.07 17:00:00  Test Ger30Sb617,H1: 12223.5
0	08:20:13.411	2017.04.07 18:00:00  Test Ger30Sb617,H1: 12243.5
0	08:20:13.417	2017.04.07 19:00:00  Test Ger30Sb617,H1: 12253.5
0	08:20:13.425	2017.04.07 20:00:00  Test Ger30Sb617,H1: 12273.0
0	08:20:13.432	2017.04.07 21:00:00  Test Ger30Sb617,H1: 12247.5
 
Irwan Adnan:

I could be wrong, but from my experience, when I was backtesting my custom indicator/EA which include some timeframes (eg 5, 15, 30, H1, H4, D1) using same standard indicator with same parameters (except for that timeframe parameter), I got on my chart there is only a current timeframe value was changed while value of other timeframes were not.


Sorry, I am wrong. What I actually backtested was running an EA with an indicator of multiple TF.

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
      static datetime lastbar=0;
   if(Time[0]!=lastbar)
     {
      Comment("\nM5 = ",iHigh(_Symbol,PERIOD_M5,0)," ; M15 = ",iHigh(_Symbol,PERIOD_M15,0)," ; H1 = ",iHigh(_Symbol,PERIOD_H1,0)," ; H4 = ",iHigh(_Symbol,PERIOD_H4,0)," ; D1 = ",iHigh(_Symbol,PERIOD_D1,0)," ; W1 = ",iHigh(_Symbol,PERIOD_W1,0));    
      Print("M5 = ",iHigh(_Symbol,PERIOD_M5,0)," ; M15 = ",iHigh(_Symbol,PERIOD_M15,0)," ; H1 = ",iHigh(_Symbol,PERIOD_H1,0)," ; H4 = ",iHigh(_Symbol,PERIOD_H4,0)," ; D1 = ",iHigh(_Symbol,PERIOD_D1,0)," ; W1 = ",iHigh(_Symbol,PERIOD_W1,0));    
      lastbar=Time[0];
     }

//--- return value of prev_calculated for next call
   return(rates_total);
  }

And the result is :

2017.04.09 18:31:57.853 2017.04.07 10:00:00  coba Indicator GBPUSD,H1: M5 = 1.244 ; M15 = 1.244 ; H1 = 1.2464 ; H4 = 1.2477 ; D1 = 1.2494 ; W1 = 1.2555
2017.04.09 18:31:58.213 2017.04.07 11:00:00  coba Indicator GBPUSD,H1: M5 = 1.244 ; M15 = 1.244 ; H1 = 1.2459 ; H4 = 1.2477 ; D1 = 1.2494 ; W1 = 1.2555
2017.04.09 18:31:58.540 2017.04.07 12:00:00  coba Indicator GBPUSD,H1: M5 = 1.244 ; M15 = 1.244 ; H1 = 1.2434 ; H4 = 1.2477 ; D1 = 1.2494 ; W1 = 1.2555
2017.04.09 18:31:58.899 2017.04.07 13:00:00  coba Indicator GBPUSD,H1: M5 = 1.244 ; M15 = 1.244 ; H1 = 1.2429 ; H4 = 1.2477 ; D1 = 1.2494 ; W1 = 1.2555
2017.04.09 18:31:59.164 2017.04.07 14:00:00  coba Indicator GBPUSD,H1: M5 = 1.244 ; M15 = 1.244 ; H1 = 1.2424 ; H4 = 1.2477 ; D1 = 1.2494 ; W1 = 1.2555
2017.04.09 18:31:59.461 2017.04.07 15:00:00  coba Indicator GBPUSD,H1: M5 = 1.244 ; M15 = 1.244 ; H1 = 1.2418 ; H4 = 1.2477 ; D1 = 1.2494 ; W1 = 1.2555
2017.04.09 18:32:00.406 2017.04.07 16:00:00  coba Indicator GBPUSD,H1: M5 = 1.244 ; M15 = 1.244 ; H1 = 1.24 ; H4 = 1.2477 ; D1 = 1.2494 ; W1 = 1.2555
2017.04.09 18:32:00.920 2017.04.07 17:00:00  coba Indicator GBPUSD,H1: M5 = 1.244 ; M15 = 1.244 ; H1 = 1.2391 ; H4 = 1.2477 ; D1 = 1.2494 ; W1 = 1.2555
2017.04.09 18:32:01.201 2017.04.07 18:00:00  coba Indicator GBPUSD,H1: M5 = 1.244 ; M15 = 1.244 ; H1 = 1.239 ; H4 = 1.2477 ; D1 = 1.2494 ; W1 = 1.2555
2017.04.09 18:32:01.498 2017.04.07 19:00:00  coba Indicator GBPUSD,H1: M5 = 1.244 ; M15 = 1.244 ; H1 = 1.2396 ; H4 = 1.2477 ; D1 = 1.2494 ; W1 = 1.2555
2017.04.09 18:32:01.654 2017.04.07 20:00:00  coba Indicator GBPUSD,H1: M5 = 1.244 ; M15 = 1.244 ; H1 = 1.2383 ; H4 = 1.2477 ; D1 = 1.2494 ; W1 = 1.2555
2017.04.09 18:32:01.825 2017.04.07 21:00:00  coba Indicator GBPUSD,H1: M5 = 1.244 ; M15 = 1.244 ; H1 = 1.2376 ; H4 = 1.2477 ; D1 = 1.2494 ; W1 = 1.2555
2017.04.09 18:32:01.997 2017.04.07 22:00:00  coba Indicator GBPUSD,H1: M5 = 1.244 ; M15 = 1.244 ; H1 = 1.2379 ; H4 = 1.2477 ; D1 = 1.2494 ; W1 = 1.2555
2017.04.09 18:32:02.106 2017.04.07 23:00:00  coba Indicator GBPUSD,H1: M5 = 1.244 ; M15 = 1.244 ; H1 = 1.2371 ; H4 = 1.2477 ; D1 = 1.2494 ; W1 = 1.2555