I'm trying to write a simple indicator, that compares the current bar high value with the previous bar high value as follows:
if (High[0]<High[1])
{
res=100;
}
However, I'm getting the run time error: Error on Calling OnBarUpdate....on bar 0. You are accessing an index with a value that is invalide since its out of range.
1. Can someone explain why I get that error message?
2. Is there a way to know how many bars are loaded into the cart (i.e. In case I need to look back to find whether a condition existed in the past).
Thank you.
Comment