The code closes positions and disables strategy, but it doesn't remove active orders. My Stop Loss and Profit target orders remain open after the strategy is disabled.
Is there any way I can get a clean close of all active orders.
//Friday Code
if (Time[0].DayOfWeek == DayOfWeek.Friday && ToTime(Time[0]) >= 133000)
{
if (Position.MarketPosition == MarketPosition.Long)
{
ExitLong(@"LongPos");
}
else if (Position.MarketPosition == MarketPosition.Short)
{
ExitShort(@"ShortPos");
}
if (State == State.Realtime)
{
SetState(State.Terminated);
Print("Condition not met. Disabling Strategy" + Time[0].ToString());
return;
}
}
Comment