https://www.mql5.com/en/docs/eventfunctions/eventsettimer
From the doc, I can see there is no timer ID. No way to tell which is which, so there is only one timer is allowed in each EA?
Usually one timer with lesser period is sufficient to invoke all tasks with larger periods. What is your usecase that requires many timers?
Thanks for confirming this for me. I just feel as a script language, MQL should allow multiple timers, like Javascript.
BTW, you may consider a timer (conceptually) as an additional thread. BUT, in MQL5 there is only 1 thread per EA. So there is only 1 timer.
angevoyageur:
Yes and as you said earlier, you can use a lesser period. I am curious why nicolasxu needs multiple timers.
To be honest, I have have specific plan for multiple timers now:)
I am using multiple timer events implementation. The pattern is in using the built-in timer for scheduling only the first event, and after triggered and ran the timer event handler, it reschedules the timer for the next nearest event. It works well.
And considering the concurrent timer thread - it is not possible unless there is implemented some mechanism for synchronized multiple-thread access to objects.
I am using multiple timer events implementation. The pattern is in using the built-in timer for scheduling only the first event, and after triggered and ran the timer event handler, it reschedules the timer for the next nearest event. It works well.
And considering the concurrent timer thread - it is not possible unless there is implemented some mechanism for synchronized multiple-thread access to objects.
Nice idea, thanks! =D

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
https://www.mql5.com/en/docs/eventfunctions/eventsettimer
From the doc, I can see there is no timer ID. No way to tell which is which, so there is only one timer is allowed in each EA?