I’m trying to move the stop loss to breakeven when the condition Close[0] <= priceToMove is met. However, when the price closes above priceToMove, the stop loss reverts back to its original position, which is stopLoss.
How can I ensure that once the condition Close[0] <= priceToMove is met, the stop loss doesn’t move back to its original position?
Thanks
The code is in OnBarUpdate
double breakevenPrice = Position.AveragePrice - (10 / tickValue) * TickSize;
double priceToMove = Position.AveragePrice - (80 / tickValue) * TickSize;
if (Position.MarketPosition == MarketPosition.Flat && TriggerCondition
)
{
EnterShort(Convert.ToInt32(1), "ShortEntry");
}
ExitShortStopMarket(Convert.ToInt32(1), stopLoss, "SL", "ShortEntry");
if (Position.MarketPosition == MarketPosition.Short && Close[0] <= priceToMove
)
{
ExitShortStopMarket(Convert.ToInt32(1), breakevenPrice, "SL", "ShortEntry");
}

Comment