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.
203704
New article MQL5 Cookbook - Creating a ring buffer for fast calculation of indicators in a sliding window has been published:
The ring buffer is the simplest and the most efficient way to arrange data when performing calculations in a sliding window. The article describes the algorithm and shows how it simplifies calculations in a sliding window and makes them more efficient.
At the start of the calculation, the indicator simply adds new values to the ring buffer of the moving average. You do not have to control the number of added values. All calculations and removals of obsolete elements occur automatically. If the indicator is called when changing the price of the last bar, the last moving average value should be replaced with a new one. The ChangeValue method is responsible for that.
The graphical display of the indicator is equivalent to the standard moving average:
Fig. 1. The simple moving average calculated in the ring buffer
Author: Vasiliy Sokolov