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 ... ?
All the code within OnTimer() not executed.
So the OnTimer(), work or don't work in the 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.
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.
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.
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!!");
}
}

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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.