Limit to 200 barCount in loop

The issue is about exceeding existing index range going from 0 to Barcount-1. If for example your symbol's array is just 100 elements large but on the other hand you do this

 for ( i = BarCount-200; i < BarCount; i++ )

or

 for ( i = 200; i < BarCount; i++ )

or this

 for ( i = BarCount-123; i < BarCount; i++ )

or

 for ( i = BarCount-123; i < 12345; i++ )

or totally worse

 for ( i = BarCount-123; i < BarCount+123; i++ )

etc.

without generally taking care of available bars then start index will become negative on one end and in last example in addition you try to become larger than available barcount. It simply exceeds barcount range (you try to access non existing elements) in such cases. That's what it is about. That is why AFL engine will return error message.

As the KB article from upper link says. Don't make assumptions on number of available bars but simply take precautions in your code so that it works without any errors on any number of available bars. Examples are in there already.

Another example precaution

 for ( i = Max(0, BarCount-200); i < BarCount; i++ )
2 Likes