On execution of the Stop Loss. I should have no market position and then should promptly go and recreate one.
The thing is that the new order appears to be ignored even though it is readily apparent in the chart
protected override void OnExecution(IExecution execution)
if
(longOrder != null && longOrder == execution.Order && execution.Order.OrderState == OrderState.Filled)
{
stopOrder = SubmitOrder(0, OrderAction.SellShort, OrderType.StopLimit, 1, tickPrice +2 * TickSize, tickPrice +2 * TickSize, "Oil", "Short limit entry");
}
else if (shortOrder != null && shortOrder == execution.Order && execution.Order.OrderState == OrderState.Filled)
{
stopOrder = SubmitOrder(0, OrderAction.BuyToCover, OrderType.Stop, 1, tickPrice -2 * TickSize, tickPrice -2 * TickSize, "Oil", "Stop loss short");
}
// (if stopOrder is executed then the long / short position must have been closed
else if
( Position.MarketPosition == MarketPosition.Flat)
{
shortOrder = longOrder = null;
}

Comment