I have already given you an example of just that, from the CodeBase, in my post #6.
That CodeBase publication serves as an example for both "live" and/or historical tick data. The process is the similar.
I guess this is it then, it's complicated, but I guess this is the way to go about it in mql5. I couldn't find something like that, so thanks for posting
As far as I have experienced, it does not skip ticks....
The purpose of this function is work with the data passed in the parameters, which are ohlc bars, not tick data. To check need use CopyTicks in OnCalculate to know how many ticks has arrived since the last call. Also the result will depends on the liquidity of the symbol, as in some markets and symbol we may have tens of ticks every milisecond while in others just feel ticks by minute.
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.
Samuel Manoel De Souza #: The purpose of this function is work with the data passed in the parameters, which are ohlc bars, not tick data. To check need use CopyTicks in OnCalculate to know how many ticks has arrived since the last call. Also the result will depends on the liquidity of the symbol, as in some markets and symbol we may have tens of ticks every milisecond while in others just feel ticks by minute.
On symbols with tick volume, this should be enough for testing. Although the OnCalculate will be called for every tick update, also for those not contributing to tick volume.
And, no, OnCalculate is called for tick updates as well... not only for ohlc data on period basis.
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.
This passage is related to OnTick event handling, not OnCalculate.
OnCalculate, as I will show with code, is called for each tick arrived, and these calls are queued and processed one by one, without skipping any ticks.
Dominik Egert #: This passage is related to OnTick event handling, not OnCalculate. OnCalculate, as I will show with code, is called for each tick arrived, and these calls are queued and processed one by one, without skipping any ticks.
If it is indeed the case that OnCalculate gets called for EVERY tick, then that would mean that during high volatility, the indicators (which share a single thread with the chart itself), can easily "stall" that thread and "freeze" the chart completely. That seems somewhat "dangerous".
"The Calculate event is generated only for indicators right after the Init event is sent and at any change of price data. It is processed by the OnCalculate function."
So, it could be interpreted the way you describe, and it would explain why charts tend to stall a lot during high impact news.
I sure hope that is not the case, however. If it is, it may make me want to rethink some of my EAs and have them recalculate everything internally without using Indicators.
Fernando Carreiro #: If it is indeed the case that OnCalculate gets called for EVERY tick, then that would mean that during high volatility, the indicators (which share a single thread with the chart itself), can easily "stall" that thread and "freeze" the chart completely. That seems somewhat "dangerous".
I was to say that, but i though the documentation was enough to proof the point when it says " 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. "
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I have already given you an example of just that, from the CodeBase, in my post #6.
That CodeBase publication serves as an example for both "live" and/or historical tick data. The process is the similar.
I guess this is it then, it's complicated, but I guess this is the way to go about it in mql5. I couldn't find something like that, so thanks for posting
No, I did not say that it does not "skip" ticks. That is incorrect. What I said was that it processes "tick events".
It processes ticks in the same way as OnTick() and It DOES SKIP ticks if the processing takes too long.
Are you sure OnCalculate() skips ticks??
EDIT:
As far as I have experienced, it does not skip ticks....
It was a long time ago when I experimented. However, since MetaTrader has evolved a lot, I may be wrong now. I will have to test it again.
Also, when the OnCalculate() takes too long to process, MetaTrader logs a warning to the Experts log.
Are you sure OnCalculate() skips ticks??
EDIT:
As far as I have experienced, it does not skip ticks....
To check need use CopyTicks in OnCalculate to know how many ticks has arrived since the last call.
Also the result will depends on the liquidity of the symbol, as in some markets and symbol we may have tens of ticks every milisecond while in others just feel ticks by minute.
See documentation.
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.
It was a long time ago when I experimented. However, since MetaTrader has evolved a lot, I may be wrong now. I will have to test it again.
Also, when the OnCalculate() takes too long to process, MetaTrader logs a warning to the Experts log.
The purpose of this function is work with the data passed in the parameters, which are ohlc bars, not tick data.
To check need use CopyTicks in OnCalculate to know how many ticks has arrived since the last call.
Also the result will depends on the liquidity of the symbol, as in some markets and symbol we may have tens of ticks every milisecond while in others just feel ticks by minute.
See documentation.
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.
If it is indeed the case that OnCalculate gets called for EVERY tick, then that would mean that during high volatility, the indicators (which share a single thread with the chart itself), can easily "stall" that thread and "freeze" the chart completely. That seems somewhat "dangerous".
EDIT: The documentation does in fact state ....
So, it could be interpreted the way you describe, and it would explain why charts tend to stall a lot during high impact news.
I sure hope that is not the case, however. If it is, it may make me want to rethink some of my EAs and have them recalculate everything internally without using Indicators.
If it is indeed the case that OnCalculate gets called for EVERY tick, then that would mean that during high volatility, the indicators (which share a single thread with the chart itself), can easily "stall" that thread and "freeze" the chart completely. That seems somewhat "dangerous".
I was to say that, but i though the documentation was enough to proof the point when it says " 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. "