Download MetaTrader 5
To add comments, please log in or register
Deposit to your account via WebMoney
ZenForex.com
217
ZenForex.com 2010.11.21 22:38 

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
Rashid Umarov
Admin
11702
Rashid Umarov 2010.11.22 09:36  

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.
ZenForex.com
217
ZenForex.com 2010.11.22 10:57  
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. 

Rashid Umarov
Admin
11702
Rashid Umarov 2010.11.22 13:36  
Thank you. Wait for a fixed build, please.

/
To add comments, please log in or register