I would like to move the stop loss two times only.
Can anybody help me? I'm not programmer and I have no idea how to do it
First time once the price is greater than "n" ticks than entry price, set stop loss in the middle betwen stop loss price and breakeven.
Second time once the price is greater then "m" ticks than entry price, set stop loss to break even price + "l" tick.
My presend stop loss setting below.
Thanks for help in advance.
Rgds
Czarek
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Resets the stop loss to the original value when all positions are closed
if (Position.MarketPosition == MarketPosition.Flat)
{
SetStopLoss(CalculationMode.Ticks, stop);
}
// If a long position is open, allow for stop loss modification to breakeven
else if (Position.MarketPosition == MarketPosition.Long)
{
// Once the price is greater than entry price+breakeven ticks, set stop loss to breakeven
if (Close[0] > Position.AvgPrice + breakeven * TickSize)
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice);
}
}
// If a short position is open, allow for stop loss modification to breakeven
else if (Position.MarketPosition == MarketPosition.Short)
{
// Once the price is lower than entry price-breakeven ticks, set stop loss to breakeven
if (Close[0]+ breakeven * TickSize < Position.AvgPrice)
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice);
}
Comment