whitebloodcell:
Could someone please explain how to ensure the indicator calculates all bars available on the first run, and then only the bar that most recently appears. My indicator calculates what I want on the first run, but then does nothing. I can't figure out why.
I recommend you read the documentation. This is good article on it. The loop you want is:
int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- int limit; if(prev_calculated==0) //--- If it is the first call go through all bars limit=0; else limit=rates_total-1; //--- Else just check the most current bar that has not yet finished for(int i=limit;i<rates_total-1;i++) { //--- Your logic here } //--- return value of prev_calculated for next call return(rates_total);
whitebloodcell:
Thanks for your help. I wanted to calculate from left to right, and thought I needed to decrement therefore, but I was confused in the way the bars are numbered.
If you want to do it this way then you can use ArraySetAsSeries to change the indexing order.
Thanks for your help. I wanted to calculate from left to right, and thought I needed to decrement therefore, but I was confused in the way the bars are numbered.

Documentation on MQL5: Array Functions / ArraySetAsSeries
- www.mql5.com
Array Functions / ArraySetAsSeries - Documentation on MQL5

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
Could someone please explain how to ensure the indicator calculates all bars available on the first run, and then only the bar that most recently appears. My indicator calculates what I want on the first run, but then does nothing. I can't figure out why.