What happens if OnTimer triggers while OnTick is running, or vice versa?

To add comments, please log in or register
Derk Wehler
343
Derk Wehler  

In OnTick documentation, it says a new tick is ignored if OnTick is still running.  Is OnTimer ignored too?

And vice versa, what happens to OnTick if OnTimer is already running?

William Roeder
20210
William Roeder  

It is added to the queue only once and will run as soon as the current function returns. Additional ticks are ignored, because OnTick is already in the queue when OnTick is running.

The queue is used for OnTick, OnTimer, ChartApplyTemplate, ChartIndicatorDelete, ChartNavigate, ChartOpen, ChartScreenShot, ChartSet…, etc.

A program gets events only from the chart it is running on. All events are handled one after another in the order of their receipt. If the queue already contains the NewTick event or this event is in the processing stage, then the new NewTick event is not added to mql5 application queue. Similarly, if the ChartEvent is already in an mql5 program queue or such an event is being handled, then a new event of this type is not placed into a queue. Timer event handling is processed in the same way — if the Timer event is already in the queue or is being handled, no new timer event is set into a queue.

Event queues have a limited but sufficient size, so the queue overflow is unlikely for a correctly developed program. When the queue overflows, new events are discarded without being set into a queue.
          Event Handling - MQL4 Reference

Derk Wehler
343
Derk Wehler  
William Roeder:

It is added to the queue only once and will run as soon as the current function returns. Additional ticks are ignored, because OnTick is already in the queue when OnTick is running.

The queue is used for OnTick, OnTimer, ChartApplyTemplate, ChartIndicatorDelete, ChartNavigate, ChartOpen, ChartScreenShot, ChartSet…, etc.

Thank you.

To add comments, please log in or register