How to set a priority in a multi symbol rotational strategy
Author: gfparker
Creation Date: 6/23/2010 10:05 AM
profile picture

gfparker

#1
I have the following strategy that runs on the DOW 30 symbols. In backtesting if I run out of enough capital to make all the trades, I want to pick the symbols with the lowest rsi to trade. My backtesting is 1/1/2007 thru 12/31/2009, $100,000 capital $10,000 per trade.
CODE:
Please log in to see this code.

My problem is that during backtesting the code throws the following errors and the backtest fails for that set of parameters.
Error processing symbol BA Object reference not set to an instance of an object.
Error processing symbol CAT Object reference not set to an instance of an object.
Error processing symbol CVX Object reference not set to an instance of an object.
Error processing symbol KFT Object reference not set to an instance of an object.
Error processing symbol MMM Object reference not set to an instance of an object.
Error processing symbol UTX Object reference not set to an instance of an object.
The errors look to be the trades that would be generated on 12/31/2009, the last day of the backtest. (Similar errors get throw running in realtime for the current day.)
I assume it's because the strategy is trying to set a position priority on a trade that hasn't occurred but I don't know how to fix that. Any help would be appreciated.
profile picture

Eugene

#2
QUOTE:
I assume it's because the strategy is trying to set a position priority on a trade that hasn't occurred but I don't know how to fix that.

You have this piece of the puzzle solved down in the commented code, but problematic just above it:
CODE:
Please log in to see this code.

Should be:
CODE:
Please log in to see this code.

There are other things to focus on such as ExitAtLimit preceding ExitAtStop.

P.S. More on Object reference not set to an instance of an object in the Wiki.
profile picture

gfparker

#3
I originally had the statement as your should be above, but the code still throws the same errors either way.
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).