Profit target and stop loss are set by the set commands and the ES and MES each have their own signals. I believe this is an order handling issue, but I have no idea how to resolve it. I'm hoping to find help here before going down the unmanaged order rabbit hole.
if (stopTriggered == true && secondChanceComplete == false && EnableSecondChance == true ) { Print(String.Format("Second Chance Activated | {0} | Mini: {1} | Micro: {2}", scQuantityFull,scMiniQuantityInt, scMicroQuantityInt )); //execute second chance trade SetProfitTarget( "SCEntry", CalculationMode.Price, scTargetPrice); SetStopLoss( "SCEntry", CalculationMode.Price, scStopPrice, false); if (MicroInstrument == true) { SetProfitTarget( "SCMicroEntry", CalculationMode.Price, scTargetPrice); SetStopLoss( "SCMicroEntry", CalculationMode.Price, scStopPrice, false); } if (direction == "SHORT") { if (MiniQuantityInt > 0) { EnterLongLimit(miniTradeDataSeries, liveUntilCancelled, scMiniQuantityInt, scEntryPrice, "SCEntry" ); } if (MicroInstrument == true) { if (MicroQuantityInt > 0) { EnterLongLimit(microTradeDataSeries, liveUntilCancelled, scMicroQuantityInt, scEntryPrice, "SCMicroEntry" ); } } } else if (direction == "LONG") { if (MiniQuantityInt > 0) { EnterShortLimit( miniTradeDataSeries, liveUntilCancelled, scMiniQuantityInt, scEntryPrice, "SCEntry"); } if (MicroInstrument == true ) { if (MicroQuantityInt > 0) { EnterShortLimit( microTradeDataSeries, liveUntilCancelled, scMicroQuantityInt, scEntryPrice, "SCMicroEntry"); } } } secondChanceComplete = true; //ensures second chance is only run once per day }
stopTriggered is set to true during OnOrderUpdate when stop order is filled
if (order.Name == "Stop loss") stopOrder = order; if (stopOrder != null && stopOrder.IsBacktestOrder && State == State.Realtime) stopOrder = GetRealtimeOrder(stopOrder); if (stopOrder != null && stopOrder == order) { if (order.OrderState == OrderState.Filled) stopTriggered = true; }
Comment