If the difference between "rates_total" and "prev_calculated" is not equal to 0 and not equal to 1, then recalculate all indicator values. If this happens, it is very rare (I add a message to the experts’ journal when calculating indicators “from scratch”)
But I don't really like this implementation (it's quite old). This is the first thing I found right now. I remember that I had better implementations, but I deleted them after the customer confirmed that they worked correctly.
Therefore, I emphasize once again: take this as pseudocode
This doesn't look good because the return value of this function is not checked. I remember that I simply changed my mind about checking it, since in the case of ArraySetAsSeries, if the error did not occur during the first test, then it will definitely never occur.
William Roeder #: If a history update or refresh, adds bars to history, how do you detect it and reset prev_calculated to zero or recompute all bars?
If the terminal adds bars to the history, then notCalculated will be greater than 1, which will lead to the recalculation of all indicator values. I don't think the terminal will only add 1 bar when loading history.
William Roeder #: Why are you writing nineteen (19) lines above, instead of just a single iCustom call?
It requires a lot more lines than 19😄
Sometimes customers ask to hide indicators (so that it would be impossible to find out which indicators are used)
This often provides an opportunity to improve performance
If you use ArrayCopyRates to receive data from another timeframe, then calculating indicators on the MqlRates array (which you pass to ArrayCopyRates) ensures the synchronization of the MqlRates array and indicator values
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.
If new history arrives, any remember Bars or previous Bars will be misleading.
There have never been any problems with this in MT4:
Forum on trading, automated trading systems and testing trading strategies
Include a personalized indicator in an Expert Advisor
Vladislav Boyko, 2024.03.31 18:58
If the difference between "rates_total" and "prev_calculated" is not equal to 0 and not equal to 1, then recalculate all indicator values. If this happens, it is very rare (I add a message to the experts’ journal when calculating indicators “from scratch”)
Forum on trading, automated trading systems and testing trading strategies
Include a personalized indicator in an Expert Advisor
Vladislav Boyko, 2024.04.01 01:50
This is not difficult to implement in MT4. Below is the method code of one of my old advisors. Think of it as pseudocode
This method controls the sizes of buffers and returns rates_total and prev_calculated
But I don't really like this implementation (it's quite old). This is the first thing I found right now. I remember that I had better implementations, but I deleted them after the customer confirmed that they worked correctly.
Therefore, I emphasize once again: take this as pseudocode
Forum on trading, automated trading systems and testing trading strategies
Include a personalized indicator in an Expert Advisor
Vladislav Boyko, 2024.04.01 01:50
This doesn't look good because the return value of this function is not checked. I remember that I simply changed my mind about checking it, since in the case of ArraySetAsSeries, if the error did not occur during the first test, then it will definitely never occur.
I would like to hear how you think about this solution:
If a history update or refresh, adds bars to history, how do you detect it and reset prev_calculated to zero or recompute all bars?
If the terminal adds bars to the history, then notCalculated will be greater than 1, which will lead to the recalculation of all indicator values. I don't think the terminal will only add 1 bar when loading history.
Forum on trading, automated trading systems and testing trading strategies
Include a personalized indicator in an Expert Advisor
Vladislav Boyko, 2024.04.01 01:50
Why are you writing nineteen (19) lines above, instead of just a single iCustom call?
It requires a lot more lines than 19😄