What does this standard code do?

 

Can someone explain to me what does this standard code-block on top of most indicators do?

I looked up the documentation of these functions, but I don't understand what does it accomplish.

   int    counted_bars=IndicatorCounted();
//----
   int limit=barsBack-counted_bars;
   if(counted_bars>0) limit++;
   
   for(int i=limit;i>=0;i--){

Thanks.

 

It is basically to only calculate and draw on the indicator those newly formed bars plus one (ie the limit++).

If you don't have this, it will have to re-calculate/redraw all the bars in the indicator each time you get a tick, and that would be horrific for performance.

Reason: