Download MetaTrader 5

In backtest OnTimer() not performs

To add comments, please log in or register
Mohammad Ali
21225
Mohammad Ali  

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.

Alain Verleyen
Moderator
32372
Alain Verleyen  
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 ... ?
Mohammad Ali
21225
Mohammad Ali  
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.
Slava
Moderator
6926
Slava  
OnTimer, OnChartEvent processing not implemented yet in the Tester
ffoorr
1076
ffoorr  
So the OnTimer(), work or don't work in the tester ?
Alain Verleyen
Moderator
32372
Alain Verleyen  
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.
michael
65
michael  

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.

toriachtmql
67
toriachtmql  
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?
NickF
31
NickF  
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. 
whroeder1
15554
whroeder1  
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;
}
AugustoFiorucci
7
AugustoFiorucci  

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!!");
   }
}
To add comments, please log in or register