-
See How to do your lookbacks correctly #9 - #14 & #19.
-
int limit = rates_total - MathMax(LOOKBACK, prev_calculated); int values_to_copy = limit; ⋮ for(int i=limit-1; i>-1 && !IsStopped(); i--) ⋮ return rates_total-1;
Amazing! It worked. I have been trying to fix this for a while. Thank you.
Comparing your edits to the code and your other lookback examples, I think I'm beginning to understand how it works. I have to do more research to figure out where I went wrong.
I had previously used a version of the code below when I first ran into problems. Unfortunately, it didn't work because I messed up somewhere.
for(int iBar = Bars(_Symbol,PERIOD_CURRENT)-1-MathMax(lookback, prev_calculated); iBar >= 0; --iBar){ } return rates_total-1; // Recalculate current bar next tick.
Thanks again for your help!

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
Hi, I created a custom indicator that doesn't update or move along with new candles on the chart. I think it has something to do with the way I am using rates_total and prev_caculated but I'm not sure. Currently, my array buffers are "TRUE" for ArraySetAsSeries() and I have tried several different methods to access them with varying result. Please see the code I am using below -
Any help form someone skilled in MQL5 would be appreciate.
Thanks