As per the documentation, EAs do not get called on every tick. If a tick event is being processed then any subsequent tick events that occur during that time, are not queued.
...
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.
...
- www.mql5.com
It should be noted that not only expert's OnTick event, but indicator's OnCalculate event does not guarantee to present every single tick to your program.
If you want to process all ticks, you should call CopyTicks function for the time span passed since previously processed tick - you can find an example of this in the algotrading book - search for processAllTicks().
It should be noted that not only expert's OnTick event, but indicator's OnCalculate event does not guarantee to present every single tick to your program.
If you want to process all ticks, you should call CopyTicks function for the time span passed since previously processed tick - you can find an example of this in the algotrading book - search for processAllTicks().
The fact that you successfully received all ticks in OnCalculate online during occasional test does not mean that it will can happen every time. I suppose it depends from many factors (number of programs running, CPU load, event queue size). Actually it's a [hidden and therefore undocumented] implementation specific of the terminal which can change in future in different ways. I'd not take it for granted that your program will receive all ticks in OnCalculate.
If I'm not mistaken, I remember similar tests in the past, where according to tick counters, they are skipped by the handlers. I don't have time to search forums for it right now.
- www.mql5.com
The fact that you successfully received all ticks in OnCalculate online during occasional test does not mean that it will can happen every time. I suppose it depends from many factors (number of programs running, CPU load, event queue size). Actually it's a [hidden and therefore undocumented] implementation specific of the terminal which can change in future in different ways. I'd not take it for granted that your program will receive all ticks in OnCalculate.
If I'm not mistaken, I remember similar tests in the past, where according to tick counters, they are skipped by the handlers. I don't have time to search forums for it right now.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
So I was experimenting to try and fully understand the way that Experts and Indicators work, especially for slow indicators.
But when I did a base-case test, just an Expert with a fast indicator, I noticed that the OnTick (or at least the print inside the ontick) does not call sometimes, even though the indicators detected a tick.
To demo the problem, here is an indicator
Here is an expert:
And here is some sample output from the Experts tab.
The indicator is called 2 times before the expert is called in some cases.
How can this happen?
Does the Expert wait for the indicators OnCalculate to complete all of it's ticks before running one time? Or is this a bug?