Hm ok, but I thought OnCalculate is per-bar data. I assumed that to gather tick data, we have to go back in time until after a bar (of minimum 1 minute) has occurred. Let me know if I'm mistaken here, and if so, I'd like to see a small example of a for loop capturing ticks in OnCalculate (nested for loop I'm guessing)
For an actual example, see my second test indicator code. It retrieves all ticks coming in on live markets.
Should give you an idea on how to get tick data as you require.
@Dominik Egert was correct in his inital stament. It is called for all live tick. i don't know for historical.
This is my test. I tested with and without delay. Event when the chart freezes the result is the same.
Actually, OnCalculate is only called by new ticks.
Even the initial run is first triggered by a tick arrival.
So you get the first live tick, then you calculate all historical periods in your loop, you return rates_total, then you get tick updates.
Even if you are not done with the history, and return a value lower than rates_total, your next call will be triggered only by a new tick arrival.
That's why I have the split calculations called step interval in my testing code, to show this. And to show how to make sure, the terminal does not complain about slow indicator calculations.
Actually, OnCalculate is only called by new ticks.
Even the initial run is first triggered by a tick arrival.
So you get the first live tick, then you calculate all historical periods in your loop, you return rates_total, then you get tick updates.
Even if you are not done with the history, and return a value lower than rates_total, your next call will be triggered only by a new tick arrival.
That's why I have the split calculations called step interval in my testing code, to show this. Andto show how to make sure, the terminal does not complain about slow indicator calculations.
yeah, i did edit my post. i remember it is called only once after in the initialization and for new ticks.
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.
Yes, I am beginning to see that this may indeed be the case, and it also explains why the indicators stall/freeze so much during high impact news.
Hm ok, but I thought OnCalculate is per-bar data. I assumed that to gather tick data, we have to go back in time until after a bar (of minimum 1 minute) has occurred. Let me know if I'm mistaken here, and if so, I'd like to see a small example of a for loop capturing ticks in OnCalculate (nested for loop I'm guessing)
Thanks Dominik, I will take a look at this
@Dominik Egert was correct in his inital stament. It is called for all live tick.
This is my test. I tested with and without delay. Even when the chart freezes the result is the same.

@Dominik Egert was correct in his inital stament. It is called for all live tick. i don't know for historical.
This is my test. I tested with and without delay. Event when the chart freezes the result is the same.
yeah, i did edit my post. i remember it is called only once after in the initialization and for new ticks.
@Dominik Egert was correct in his inital stament. It is called for all live tick.
This is my test. I tested with and without delay. Even when the chart freezes the result is the same.
More than 5,000 ticks in 1 minute, what symbol is that ?
WINV23, exchange is B3 in Brazil.
WINV23
I see, there is a tick on each transaction (BUY/SELL) with last/volume changes, which gives a lot more ticks than just change with Bid/Ask.
So depending of the indicator it could be useful to filter the ticks to avoid useless update.
Why is it that we multiply 1000 by the time? I've seen this in other codebase codes as well and I'm confused about this