The indicator adds a secondary series with a 1-minute period in Initialize(). As currently coded, the indicator works when it's added to a 1-minute chart or a 2-minute chart, but it fails when it's added to a 3-minute or longer period chart. When the indicator fails, the error message reads "Error on calling 'OnBarUpdate' method for indicator 'aaaWIP' on bar 0: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart."
I'd like to understand the following things.
1. Why does the indicator work for a 2-minute chart, but fail for a 3-minute chart?
2. What code do I need to add to my script to eliminate the error when the indicator is added to 3-minute or longer period charts?
Thanks in advance for help you might provide.
Comment