Looping thru chart data, Questions ?

 
I have this code..

int limit, records;
int counted_bars = IndicatorCounted();
limit = Bars - counted_bars;
if ( counted_bars < 0 ) return(0);
if ( counted_bars ==0 ) limit=Bars-1;

for(int i = 0; i < limit; i++)
{
...do something with i
records += 1;
}

Q1: So when I look at a chart is this loop for "i" going from right to left or left to right thu data.

Q2: When I do record count of bars, I get something like 2600. So to work out years of data I could take 260 trading days in a year. 2600/260 = 10 years , is this correct approx ?

Q3: I can get iclose for a bar on the chart, how do I get the date/time of the bar ?
 
1. this loop for "i" going from right to left
2. Yes, it is. But after first indicator's counting the value of records will increase every tick. Add into your code line

for(int i = 0; i < limit; i++)
{
...do something with i
records += 1;
}
 
Print("Tick at ",TimeToStr(TimeCurrent(),TIME_SECONDS)," :records=", records )
3. Time[index] and iTime(symbol_name,period_minutes,index) use ,
TimeToStr();
 
Rosh wrote:
1. this loop for "i" going from right to left
2. Yes, it is. But after first indicator's counting the value of records will increase every tick. Add into your code line

for(int i = 0; i < limit; i++)
{
...do something with i
records += 1;
}
 
Print("Tick at ",TimeToStr(TimeCurrent(),TIME_SECONDS)," :records=", records )
3. Time[index] and iTime(symbol_name,period_minutes,index) use ,
TimeToStr();


Thanks...

So with (2), when a new bar is added, say I have 2600 bars, it would be 2600+1 = 2601

Correct ?
Reason: