// if first bar of today's session, calc last 20 days average
if(Bars.FirstBarOfSession)
{
int barsCounted = 0;
for(int i = CurrentBar-1; i>=0; i--)
{
nDaysAvg += ((High[i] + Low[i] + Close[i]) / 3);
barsCounted++;
}
nDaysAvg = nDaysAvg / barsCounted;
}
My Questions:
1) Am I iterating the Bars collection backwards correctly
2) What is the best way to determine if I've processed 20 days. Currently, I'm creating a chart for 20 days and stopping when no more bars (i == 0).
3) Since I am only interested in displaying only todays 1min bars, how can I retrieve the last 20 days 1min bars used to calc the avg without having to display their bars.
thx

Comment