EventSetTimer(n) can not be backtesting?

 

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!");
  }
//+------------------------------------------------------------------+
 

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!");
  }
//+------------------------------------------------------------------+
 
Marco vd Heijden:

No.

But if need be you can

And it will print "Hello World!" every tick.
 

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 :) 

 
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

Reason: