How to check the current bar is fully completed

 

greeting,

Is there a way to check the current bar is fully completed? i would like to calculate an indicator value base on the actual closing of current bar.

 

The "current bar", bar index 0, is never complete.

If it is, then it has become bar 1, and a new and incomplete current bar has started.

 

int intPos, counted_bars=IndicatorCounted();
//----
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- the last counted bar will be recounted
if(counted_bars>0) counted_bars--;

intPos = Bars-counted_bars-1;

while (intPos>=0)

{

if (intPos != 0)

{

//calculate value

}

intPos--

}

Is the above code correct ?

 

Depending on what is in //calculate value, it might work for you.

Reason: