Error: Index was out of range
Author: dct73
Creation Date: 7/6/2009 8:36 PM
profile picture

dct73

#1
I added the chandelier stop to a strategy and ran it. It compiles and runs ok, just doesn't make any trades now. If I take out the chandelier portion and install a simple stop it works fine again. Any idea what is going on? Is it ok to post the code right here?
profile picture

Cone

#2
Not enough information. Post the code (click the CODE button), and let us know what the symbol, scale, and sizing settings are.
profile picture

dct73

#3
Here is the code. I ran it on the Nasdaq 100. Scale is daily and position size is 2% of equity. I'm getting errors that say "Parameter name: Index Index was out of range. Must be non-negative and less than the size of the collection."


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

Eugene

#4
Chandelier has absolutely nothing to do with this problem, just comment the lines out to see.

This is where the problem is:
CODE:
Please log in to see this code.

You're trying to access data [at bar-60] outside of the main loop. Correct it and the error goes away:
CODE:
Please log in to see this code.

Next problem is trying to mix the pieces of logic from a multi-position strategy with a code block that belongs to a single-position strategy:
CODE:
Please log in to see this code.

The corrected code follows:
CODE:
Please log in to see this code.
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).