If I wanted my indicator to NOT update on the current bar, would this be achieved by simply changing the "i" integer value from 0 to 1 in the code line (for (int i=0; i<limit; i++) ?
Correct . . . as far as I am aware.
IndicatorCounted() indirectl tells you how many bars you need to calculate your buffers for since last time you did it. It does this by actually telling you how many bars are the same compared to the last time IndicatorCounted() was called. First time through your start() function this will be zero bars as they have not been "seen" by Indicator Counted() before, next time through, as long as there isn't a new bar, IndicatorCounted() has "seen" all the bars and all buffer values have been calculated so Bars-1 is returned, meaning that all bars are the same as the last time so there is nothing to do.
Correct . . . as far as I am aware.
IndicatorCounted() indirectl tells you how many bars you need to calculate your buffers for since last time you did it. It does this by actually telling you how many bars are the same compared to the last time IndicatorCounted() was called. First time through your start() function this will be zero bars as they have not been "seen" by Indicator Counted() before, next time through, as long as there isn't a new bar, IndicatorCounted() has "seen" all the bars and all buffer values have been calculated so Bars-1 is returned, meaning that all bars are the same as the last time so there is nothing to do.
Thank you Raptor !!
- No need for the decrement. Contradictory information on IndicatorCounted() - MQL4 forum
- Always count down. Get in the habit.
int counted_bars=IndicatorCounted(); // Adjust for look back. E.g. iMA(PERIOD) LB=PERIOD // if (counted_bars < LOOK_BACK) counted_bars = LOOK_BACK; // Same as SetIndexDrawBegin() setting in init. for(iBar = Bars -1 -counted_bars; iBar >= 1; iBar--){ :

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello Forum, I am trying to understand the concept of Indicator Counted and as a consequence, how to distinguish between when indicators recalculate during the current bar OR not !!
( I hope I am looking at the right part of the documentation)
I've lifted the code below from the documentation https://docs.mql4.com/customind/indicatorcounted
Am still struggling to understand this, and want to ask for clarification on the following:
If I wanted my indicator to NOT update on the current bar, would this be achieved by simply changing the "i" integer value from 0 to 1 in the code line (for (int i=0; i<limit; i++) ?
Or is it more complex than this?
Thanks in advance...