A new problem with EventSetTimer

 

Hi,

I set "EventSetTimer(2)" on the first tick only and expect this "onTimer" event to fire during backtest, even in the weekend. I can't seem to get the output on the onTimer call which I assume means it is not being called.

Below pasted a simple code for testing the problem, I use build 355. 

Can  someone point the problem, or this is a bug?

 

#property copyright "Oran Leiba"

#property link      "www.etootim.com"

#property version   "1.00"


bool start = true;

//+------------------------------------------------------------------+

//| Expert initialization function                                   |

//+------------------------------------------------------------------+

int OnInit()

  {

//---

   

//---

   return(0);

  }

//+------------------------------------------------------------------+

//| Expert deinitialization function                                 |

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

  {

//---

   

  }

//+------------------------------------------------------------------+

//| Expert tick function                                             |

//+------------------------------------------------------------------+

void OnTick()

  {

//---

   if(start){

      bool setTimer = EventSetTimer(2);

      if(setTimer){

         printf("success set timer");

         start = false;

      }else{

         printf("failed set timer");

      }

   }else{

      printf("no need to set timer");

   }

  }

//+------------------------------------------------------------------+


void OnTimer(){

   printf("on timer");

}

Thanks! 

Documentation on MQL5: Working with Events / EventSetTimer
  • www.mql5.com
Working with Events / EventSetTimer - Documentation on MQL5
 

Please, properly insert code

#property copyright "Oran Leiba"
#property link      "www.etootim.com"
#property version   "1.00"

bool start = true;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---

//---
   return(0);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)

  {
//--- 

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+

void OnTick()
  {
//---
   if(start){
      bool setTimer = EventSetTimer(2);
      if(setTimer){
         printf("success set timer");
         start = false;
      }else{
         printf("failed set timer");
      }
   }else{
      printf("no need to set timer");
   }
  }
//+------------------------------------------------------------------+
void OnTimer(){
   printf("on timer");
}
MQL5.community - User Memo
  • 2010.02.25
  • MetaQuotes Software Corp.
  • www.mql5.com
You have just registered and most likely you have questions such as, "How do I insert a picture to my a message?" "How do I format my MQL5 source code?" "Where are my personal messages kept?" You may have many other questions. In this article, we have prepared some hands-on tips that will help you get accustomed in MQL5.community and take full advantage of its available features.
 
Rosh:

Please, properly insert code


Sure.

 The problem seems to exist on both Vista and XP Pro and I'm almost sure it was not happening on the previous build.

One behavior I can note, is that if you let the expert run in tester for the first time till it finishes and then you immediatly start again the testing, the timer is working properly.

But, until you complete a first round of testing with wrong behavior, the timer will not work.

Thanks. 

 
Thank you. Wait for a fixed build, please.

Reason: