I tried to use this
#region DynamicTrail()
private void DynamicTrail()
{
if (Position.MarketPosition == MarketPosition.Long && N_BU > 0)
{
// Raise stop loss to breakeven when there is at least N_BU ticks in profit
if (Close[0] >= Position.AvgPrice + N_BU * TickSize)
{
double new_sl=Position.AvgPrice + 1 * TickSize;
SetStopLoss(CalculationMode.Price, new_sl);
//Print("Переставили SL new_SL=" + new_sl);
}
}
if (Position.MarketPosition == MarketPosition.Short && N_BU > 0)
{
// Raise stop loss to breakeven when there is at least N_BU ticks in profit
if (Close[0] <= Position.AvgPrice - N_BU * TickSize)
{
double new_sl=Position.AvgPrice - 1 * TickSize;
SetStopLoss(CalculationMode.Price, new_sl);
//Print("Переставили SL new_SL = " + new_sl);
}
}
}
#endregion
but it didn't work
Comment