Discussion of article "MQL5 Cookbook - Creating a ring buffer for fast calculation of indicators in a sliding window" - page 3
You are missing trading opportunities:
- Free trading apps
- 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
Calculating only the last indicator value, and not recalculating it completely with the arrival of a new tick, is such a standard story that it is strange that you started to discuss it at all. It is doubly strange that you speak about it as some trick you have found. In reality, it is a standard for writing all indicators. It is also mentioned in the documentation. That is why absolutely everyone uses recalculation on the last bar/ tick.
I will try to answer more detailed:
There is a rather heavy indicator. It is requested in the Expert Advisor quite rarely, that is, until all conditions are triggered. For example, every, let's say, 300-1000 bars (in fact, it depends on a number of conditions, which are expressed in conditional operators). And if you get the value even once on each bar, it will be more times than the hidden indicator call in the body of conditional operators.
roughly like this.
In principle, limit with this approach should always equal P.I'll try to give you a more detailed answer:
there is a rather heavy indicator. In the Expert Advisor it is requested quite rarely, that is, until all conditions are triggered. For example, every, let's say, 300-1000 bars (in fact, it depends on a number of conditions, which are expressed in conditional operators). And if you get the value even once on each bar, it will be more times than the hidden indicator call in the body of conditional operators.
This approach, by the way, does not always give savings. Because the missed bars are still calculated when the indicator is called.
But if I know that the condition will be fulfilled rarely, I use this method, and if the indicator is called often, it is better to count the whole history.
And of course, I should calculate only a new bar, as the old ones are already known, it is clear.
Now I thought that it is necessary to start strictly from P without comparison
if (limit > P)limit=P;//эту строку вообще убрать и сделать сразу limit=P;If in the cycle the calculation starts from P, and it is equal to 10, for example, then the calculation will be starting from 10 bar.
But, it is not so important, we can leave it as it is. It's not worth it.
"Missed bars are still calculated when the indicator is called " can you be more detailed?
To be honest, now I have such indicators only on one bar zero or the first.
For example, here is the main part of the code of one of them:
That is, these are indicators for the tester. Of course, they will not be used for visualisation, you can't see anything in them).
But, a ring buffer will be needed if the indicator consists of several buffers, where one array is built from another.
"Missed bars are still calculated when the indicator is called " can you be more detailed?
Let's assume that the indicator was called when there were 1000 bars on the chart, it counted them. The next call - bars 1001, it counted one bar.
But if the next call will be when the bars are already 1500, it will count all new (499) bars.
To be honest, now I have such indicators meaning only on one bar zero or the first bar.
Then what is the point of indicators at all? Transfer these calculations in the form of a function in the Expert Advisor, it will be even faster.
I will try to answer more detailed:
The indicator is calculated on every bar, regardless of whether you call it or not. Read the specification.
If you want real acceleration, move the calculations inside the EA. There is no other way. Full stop. All the posts about how successfully you can insert if are just funny to read.
Your topic is off-topic for this thread. Let's end it here.
Dear Vasiliy
First of all, thank you for this excellent article and its implementations with different indicators.
I would ask you whether it would be possible to post a sample of code for the section of calculating Highs/Lows with the ring buffer? I am finding difficult to get the right results when the market is running. It seems I loose the pointer when updating the changing prices with OnChangeValue() function.
Thanks in advance.
Dear Vasiliy
First of all, thank you for this excellent article and its implementations with different indicators.
I would ask you whether it would be possible to post a sample of code for the section of calculating Highs/Lows with the ring buffer? I am finding difficult to get the right results when the market is running. It seems I loose the pointer when updating the changing prices with OnChangeValue() function.
Thanks in advance.
See this example: https://www.mql5.com/en/articles/3047#c6
See this example: https://www.mql5.com/en/articles/3047#c6
I have seen it. As I have checked the examples you provided. They show the same problem I had when dealing with updating the values while the market is running. Check the Stochastic you provided. Adding a new value is not a problem, but when we try to use Stoch.ChangeLast() or OnChangeValue() in CRiMaxMin class, it does not work. It does not change the value accordingly. If you could check it or send an example of a working code, that would be very nice.
Thank you.
A great article, the man can programme!
If only the German translation wasn't so horrible!!!!!
Where can I find the English version?
Can I switch it somewhere?