I would like to put a trailing stop to my script when the market hit 2 ticks below my target, basically, if my target is 50, when the market hit 48, move up the stop to Position.AvgPrice + 2*TickSize
i calculate my target with 2 times the ATR(10) (average true range) + the Position.AvgPrice, but the value of the ATR when the position is open
here the part of my script:
entryOrderAchat = EnterLongLimit(1, Close[0], "divergence haussiere 1");
atrAchat = CurrentBar;
}
if (Position.MarketPosition == MarketPosition.Long && High[0] > Position.AvgPrice + 2*ATR(10)[atrAchat] - 2*TickSize)
{
// Checks to see if our Stop Order has been submitted already
if (stopOrderLong != null && stopOrderLong.StopPrice < Position.AvgPrice)
{
// Modifies stop-loss to breakeven + 2 tick
stopOrderLong = ExitLongStop(0, true, stopOrderLong.Quantity, Position.AvgPrice+2*TickSize, "Trailing Stop div haussiere 1", "divergence haussiere 1");
}
it is not working... i don't know if it is because the ATR is everytime a new value after each new bar or if it is anything else... the really weird stuff is that if i remove the 2* before ATR(10)[atrAchat] in the condition, it is look to take the trailing stop but with only 1 atr...
can you help ?

Comment