OnTimer question

 

Does anyone know how to access what time remains before the next OnTimer event occurs? 

I know I can  calculate it from when the event timer is set. But is there another way? I did not see anything in the documentation.

Thank you 

 
CappinJack:

Does anyone know how to access what time remains before the next OnTimer event occurs? 

I know I can  calculate it from when the event timer is set. But is there another way? I did not see anything in the documentation.

Thank you 

Why do you need this ? One solution : you can set a global variable (datetime) in the OnTimer event handler and check elapsed time comparing this variable with current time.
Documentation on MQL5: Date and Time / TimeCurrent
Documentation on MQL5: Date and Time / TimeCurrent
  • www.mql5.com
Date and Time / TimeCurrent - Documentation on MQL5
 
angevoyageur:
Why do you need this ? One solution : you can set a global variable (datetime) in the OnTimer event handler and check elapsed time comparing this variable with current time.

That is what I did.  I  use the timer event it to update some external parameters and write some files. I display the time remaining, mostly because I am curious. I started with an input variable:

input int   Opti_Sec=4;                    // hours between parameter check

 I declared a global variables:

   datetime          lastontimer;     // last ontime event 

 The I set it to the local time in the OnInit and Ontimer functions:

   lastontimer=TimeLocal();

 And when I wanted to display it, I just use the local time to calculate the time remaining:

   string cmt="Time to Next Update: "+TimeToString((Opti_Sec*60*60)-(TimeLocal()-lastontimer),TIME_SECONDS)+"\n";
 
CappinJack:

That is what I did.  I  use the timer event it to update some external parameters and write some files. I display the time remaining, mostly because I am curious. I started with an input variable:

 I declared a global variables:

 The I set it to the local time in the OnInit and Ontimer functions:

 And when I wanted to display it, I just use the local time to calculate the time remaining:

Good. I don't think there is something natively provided in MT5.