protected override void OnOrderUpdate(IOrder order)
{
if (entryOrder != null && entryOrder == order)
{
if (order.OrderState == OrderState.Cancelled)
{
entryOrder = null;
}
}
}
protected override void OnExecution(IExecution execution)
{
if (entryOrder != null && entryOrder == execution.Order)
{
entryOrder = null;
}
}
The strategy continued to work on historical data exactly as before, but when running on sim101 the output window shows this:
**NT** Error on calling 'OnBarUpdate' method for strategy 'RKSjugJuly4RealTime/c4b77d0574c74ea3825a9cfb5c08a744': Object reference not set to an instance of an object.
I have a very strong hunch (based on live testing and where things go wrong) that the issue has something to do with this block:
//End time exit, go flat, stop taking trades
if((ToTime(Time[0])>=endTime)&& (ToTime(Time[0])<=endTime + 100))
{
//added line below to cancel any resting order to reverse which might execute after the position is exited
CancelOrder(entryOrder);
entryOrder = null;
if(Position.MarketPosition == MarketPosition.Long)
{
ExitLong();
}
else if(Position.MarketPosition == MarketPosition.Short)
{
ExitShort();
}
}

Comment