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

- www.mql5.com
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";
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:

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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