if(Position.MarketPosition == MarketPosition.Long){ stopOrder = ExitLongStop(stopLoss,"Stop Losss Long",My_LONG); }
I said "almost" because it works fine in the same trading session. However, Ninjatrader cancels the stop order, place another exactly same one if the trade spans multiple sessions even if the TIF is GTC.
Another strange behavior is that if code is like the following, the stop order is in place for the next bar only and then gets cancelled and never generated again,
private IOrder stopOrder = null; protected override void OnBarUpdate(){ if(my condtions met){ EnterLong(); stopOrder = null; } if(Position.MarketPosition == MarketPosition.Long){ if( stopOrder == null;) stopOrder = ExitLongStop(stopLoss,"Stop Losss Long",My_LONG); } }
Comment