When I raise the stop-loss order to breakeven in OnBarUpdate nothing happens.
I know it has to do with the code below (from the SampleOnOrderUpdate) that shows only the EntryLong order. When I comment the lines for ExitShort order everything works just fine.
if (entryOrder != null && entryOrder == execution.Order)
{
if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
{
// Stop-Loss order 10 ticks below our entry price
stopOrder = ExitLongStop(0, true, execution.Order.Filled, execution.Order.AvgFillPrice-(10*TickSize), "StopEL1", "EL1");
// Stop-Loss order 10 ticks above our entry price
stopOrder = ExitShortStop(0, true, execution.Order.Filled, execution.Order.AvgFillPrice+(10*TickSize), "StopES1", "ES1");
// Target order 50 ticks above our entry price
targetOrder = ExitLongLimit(0, true, execution.Order.Filled, execution.Order.AvgFillPrice + 50 * TickSize, "TargetEL1", "EL1");
// Target order 50 ticks below our entry price
targetOrder = ExitShortLimit(0, true, execution.Order.Filled, execution.Order.AvgFillPrice - 50 * TickSize, "TargetES1", "ES1");
// Resets the entryOrder object to null after the order has been filled or partially filled
if (execution.Order.OrderState != OrderState.PartFilled)
{
entryOrder = null;
}
}
}

Comment