How to find out which is last bar

 

I am working on a indicator which scans bars from left to right,

When it comes at the last bar 0, what logic should I add so it recognizes it is last bar and break;

When i compare it like this

Mqlrates[];
ArraySetAsSeries(rates,true);
if(rates[0].time == scanner[0].time)
break;

I notice this not working well so looking for other solution

thanks

 
Arpit T:

I am working on a indicator which scans bars from right to left,

When it comes at the last bar 0, what logic should I add so it recognizes it is last bar and break

thanks

Bar 0. Is always the current bar on the right
 

Indicators normally do not need new bar code. They draw according to the prev_calculated value. See How to do your lookbacks correctly #9#14 & #19.

Why do you think you need new bar code?
     How To Ask Questions The Smart Way. (2004)
          The XY Problem