In backtest OnTimer() not performs

 

Dear Guys

I write a code on OnTimer() . EA open trade on time. so i write this code on there. but when i try to backtest this EA all code within OnTimer() not work. How can i do some thing that OnTimer() code work on backtest.

Thanks.

 
capilta:

Dear Guys

I write a code on OnTimer() . EA open trade on time. so i write this code on there. but when i try to backtest this EA all code within OnTimer() not work. How can i do some thing that OnTimer() code work on backtest.

Thanks.

What is the meaning of "not work" ? Not executed or you don't get the expected results or ... ?
 
angevoyageur:
What is the meaning of "not work" ? Not executed or you don't get the expected results or ... ?


All the code within OnTimer() not executed.
 
OnTimer, OnChartEvent processing not implemented yet in the Tester
 
So the OnTimer(), work or don't work in the tester ?
 
ffoorr:
So the OnTimer(), work or don't work in the tester ?
The answer from stringo is very clear. OnTimer don't work in the Strategy Tester.
 

in addition to stringo's information, does anyone know when OnTimer and OnChartEvent will be implemented in the Tester? Even an target implementation date / time period would be helpful.

Many thanks for any advice.

 
chaeljc:

in addition to stringo's information, does anyone know when OnTimer and OnChartEvent will be implemented in the Tester? Even an target implementation date / time period would be helpful.

Many thanks for any advice.

+1 for this. Any implementation plans?
 
It would  be nice to be able to run the backtester with code in OnTimer() function - some brokers only provide trading with MQL4, not with MQL5. 
 
Toriacht: Any implementation plans?

The tester doesn't run in real time, you can speed it up (32x,) and you can pause the creation of ticks and you can skip all ticks for a bar. How should the period of OnTimer change for those three scenarios?

Not likely to every run in the tester. Just check in OnTick for the tester and do the functionality. Same as Chart Event For MT4 Backtester (Migel) - MQL4 forum

enum Terminal_Mode{  MODE_LIVE, MODE_VISUAL, MODE_OPTIMIZER};
/// @returns terminal mode.
Terminal_Mode     get_modus_operandi(void){
   if(!IsTesting() )          return MODE_LIVE;
   if( IsVisualMode() )       return MODE_VISUAL;
                              return MODE_OPTIMIZER;
}
 

You can to call OnTimer()  inside of OnTick() in the backtest. Of course, the OnTimer() will run in next tick after the time you set and not in the exactly time, but I think is ok for some aplications.

datetime lastOnTimerExecution;

int OnInit() {  
   EventSetTimer(60);
   if(IsTesting()){
      OnTimer();
      lastOnTimerExecution =  TimeCurrent();
   }
   return(INIT_SUCCEEDED);
}


void OnTick(){
   if(IsTesting() && TimeCurrent() > lastOnTimerExecution+60){
      OnTimer();
      lastOnTimerExecution =  TimeCurrent();
   }
}

void OnTimer(){
   if(IsTesting()){
      Print("I am here!!");
   }
}
Reason: