EventSetTimer(n) can not be backtesting?

To add comments, please log in or register
thomas2004
337
thomas2004  

Hi,

My EA uses a Timer. It should print out "Hello World" every minute. I run this on demo live and it does as what I want. But as I back testing it, it will not print out any thing. I wonder if the EvenSetTimer() could be back tested.


//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- create timer
   EventSetTimer(60);  // seconds
      
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy timer
   EventKillTimer();
      
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
//---
   Print("Hello World!");
  }
//+------------------------------------------------------------------+
Marco vd Heijden
Moderator
8166
Marco vd Heijden  

No.

But if need be you can

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- create timer
   EventSetTimer(60);  // seconds
      
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy timer
   EventKillTimer();
      
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   OnTimer();
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
//---
   Print("Hello World!");
  }
//+------------------------------------------------------------------+
Alain Verleyen
36050
Alain Verleyen  
Marco vd Heijden:

No.

But if need be you can

And it will print "Hello World!" every tick.
Marco vd Heijden
Moderator
8166
Marco vd Heijden  

Yes.

To test things.

Of course it's possible to add some more code to check for a new M1 candle so that it tricks into 60 sec :) 

whroeder1
17944
whroeder1  
thomas2004: My EA uses a Timer. It should print out "Hello World" every minute. I run this on demo live and it does as what I want. But as I back testing it, it will not print out any thing. I wonder if the EvenSetTimer() could be back tested.

OP is asking does the timer work in the MT5 tester. It doesn't in MT4:
See In backtest OnTimer() not performs (M. Ali) - MQL4 and MetaTrader 4 - MQL4 programming forum and work around Chart Event For MT4 Backtester (Migel) - MQL4 and MetaTrader 4 - MQL4 programming forum

To add comments, please log in or register