s_end = ToTime(Time[0]) + 4100;
if (s_end == ToTime(sessionEnd))
{
if (myOrder.OrderState == OrderState.Accepted)
{
CancelOrder(myOrder);
myOrder = null;
}
}
The problem I was trying to solve is when I start the strategy, the strategy will enter a limit order based on the closing of the previous bar, which happens to be the previous session. If I don't cancel that order, then the strategy will enter a limit order at the time I start the strategy, and if that is pre-market and the market is trading at or below this price, then I get an unintended fill. But if I use this code, then sometimes I will get the following error:
Error on calling 'OnBarUpdate' method for strategy 'Pulse300LDev/bda624da93134bb8855e699a548e0674': Object reference not set to an instance of an object.
I'm thinking this is happening when my strategy has determined that there shouldn't be any limit orders, but I'm not totally sure. Help?
Rich
tradethepulse.com

Comment