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.