In C#, indexes of a collection are zero based. CurrentBar is an index and so its zero based and starts with zero. Collection.Count is 1 based. Therefore, Bars.Count will return the total number of bars.
Your code will work but I would writeit as a property that would look something like this:
{
get
{
if (!CalculateOnBarClose && CurrentBar == Bars.Count - 1)
return true;
else if (CalculateOnBarClose && CurrentBar == Bars.Count - 2)
return true;
return false;
}
}
Leave a comment: