Testing multiple timeframes as an input for optimization

 

Hi all, I am trying to test an EA on different timeframes and so I defined timeframe as an input. The code is working fine when tested on a single timeframe. 

To have the timeframe changed, I simply added the following 2 lines of code. The first one is in the global scope and second one is in the OnInit function. Otherwise I simply use _Period to select the current timeframe

input ENUM_TIMEFRAMES Timeframe = PERIOD_H1;

int OnInit(){
	ChartSetSymbolPeriod(0, NULL, Timeframe); 
...
}

The optimization is working fine, where I set the input timeframes from M1 to H1. However, when I pick the inputs I got from the optimization, and test those in a single test, I get different results. 

Any idea where those differences could come from?

Thanks 

 
Raphael A:

Hi all, I am trying to test an EA on different timeframes and so I defined timeframe as an input. The code is working fine when tested on a single timeframe. 

To have the timeframe changed, I simply added the following 2 lines of code. The first one is in the global scope and second one is in the OnInit function. Otherwise I simply use _Period to select the current timeframe

The optimization is working fine, where I set the input timeframes from M1 to H1. However, when I pick the inputs I got from the optimization, and test those in a single test, I get different results. 

Any idea where those differences could come from?

Thanks 

If you are using indicator/whatever in your EA, you have to set the timeframe to non zero, zero means current timeframe

 
Ying Siang Ng #:

If you are using indicator/whatever in your EA, you have to set the timeframe to non zero, zero means current timeframe

Thanks for your answer. I am just referring to _Period whenever I need to design the timeframe. This should work right? As ChartSetSymbolPeriod set the current chart to the desired timeframe based on my input. 

I do understand that zero means the current timeframe but it should be fine anyway with ChartSetSymbolPeriod. 

I am a bit confused how to navigate that.