Is it possible to work with live ticks in MQL5 indicators? - page 3

You are missing trading opportunities:
- Free trading apps
- Free Forex VPS for 24 hours
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
@Dominik Egert is correct in stating that the NewTick event and Calculate event are different events. So, your reference does not prove the point.
I originally thought that the OnCalculate worked the same way as OnTick, but now I am starting to wonder about it.
It says, all events
No, it does not say "all" events. it specifically mentions that only the NewTick, ChartEvent and Timer events are the only ones that don't queue up until the previous one has been processed.
Obviously, this can be open for different interpretations, but I'm beginning to side on @Dominik Egert's interpretation that the Calculate event does in fact trigger every single event, unlike these three.
@Dominik Egert is correct in stating that the NewTick event and Calculate event are different events. So, your reference does not prove the point.
I originally thought that the OnCalculate worked the same way as OnTick, but now I am starting to wonder about it.
There are diferences, but none of them will be called for every tick. I did test in 2022.
And the point is that is not effcicient to call it tick by tick, due to the indicators not run in a separete thread.
No, it does not say "all" events. it specifically mentions that only the NewTick, ChartEvent and Timer events are the only ones that not queue up until the previous one has been processed.
Obviously, this can be open for different interpretations, but I'm beginning to side on @Dominik Egert's interpretation that the Calculate event does in fact trigger every single event, unlike these three.
do not ignore the part i've marked in red.
And the point is that is not effcicient to call it tick by tick, due to the indicators not run in a separete thread.
Yes, I too did test this a long time ago, but not recently.
It is currently the weekend and most markets are closed, but I did test @Dominik Egert's test indicator on cryptos, and it did seem to generate even more events than even the tick volume could account for.
So currently, I'm reevaluating my opinion, that it in fact might be processing every event and no losing any ticks. Once the markets open up again, I will test it in more volatile situations to verify.
I am in fact ignoring it on purpose because that section is referring to how the events are sequenced.
It has nothing to do with the events being ignored if another one is being processed.
It refers to the default action and not the exceptions.
There is also a more complete explanation in the documentation which refers to the OnTick() handler only ...
Here is a more in depth testing indicator. - I guess, it would be possible to integrate more testing and debug output, but for a proof, this should serve the needs.
EDIT:
I have added a tick checking function to see if calls to OnCalculate are actually in sequence with the ticks received from the market. - I guess this will not be possible to convert to MQL4. Therefore I have added it as a function.
And fixed a bug...
EDIT2:
After testing the indicator on live markets (BTCUSD), I noticed some strange behaviours, and had to fix quite some issues. - Currently I dont know if this is working properly, as resutls I am getting are weird, to say the least. - But for sure, OnCalculate is called much more often than tick_volume is counted up, and CopyTicksRange is somewhat unreliable for copying current tick data. At least I thought. So I switched to CopyTicks and used that, now things get interesting.
OnCalculate seems to be called for every price change, and it seems not all ticks are reflected in CopyTicks result array. But I would guess, best is to see the results for yourself, and try to understand... - I am not even able to express exactly what is going on.