Only one timer is allow in one Expert Advisor

 

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?

Documentation on MQL5: Working with Events / EventSetTimer
Documentation on MQL5: Working with Events / EventSetTimer
  • www.mql5.com
Working with Events / EventSetTimer - Reference on algorithmic/automated trading language for MetaTrader 5
 
nicolasxu:

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?
 
marketeer:
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. 
 
nicolasxu:
Thanks for confirming this for me. I just feel as a script language, MQL should allow multiple timers, like Javascript. 
What to do ?
 
nicolasxu:
Thanks for confirming this for me. I just feel as a script language, MQL should allow multiple timers, like Javascript. 
JavaScript is based on closures in a great degree (every timer possesses a function object for deferred execution). MQL5 is not.
 
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.
 
marketeer:
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.
Yes and as you said earlier, you can use a lesser period. I am curious why nicolasxu needs multiple timers.
 

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:)
 
nicolasxu:
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.

 
Ex Ovo Omnia:

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