Error: Index was out of range
Author: jimcrist
Creation Date: 10/22/2009 1:15 PM
profile picture

jimcrist

#1
How do you avoid (trap the error) "Index was out of range" for old symbols that aren't being updated anymore. I specified a date range in the control panel that was incompatible with data in NT.WL. Thanks...

CODE:
Please log in to see this code.
profile picture

Cone

#2
Not sure why you need to trap the error, but you can avoid it by just putting this at the top of the Execute method -
CODE:
Please log in to see this code.

Note though, that ATR is one of those "unstable indicators". See WealthScript Programming Guide: Indicators > Stability of Indicators
profile picture

jimcrist

#3
There's data for NT from '93-'02, but when I run the script with a date range after '02, I get the error. Checking Bars.Count < 20 isn't going to help. It's not a big deal, but when I run a backtest on 2400+ symbols, it spews out a bunch of these errors into the debug window.
profile picture

Cone

#4
Why doesn't it help? The problem is that you're trying to calculate an indicator on a series that doesn't have sufficient data. If you exit the script before the indicator is created, then you avoid the error.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).