OPEN-SOURCE SCRIPT
Simplified ATR Trailing Stop

The Simplified ATR Trailing Stop will start calculating on a set date that you specify. This is great because you want to trail the price from the breakout day or even after exceeding specific price level (can be your breakeven level or even to capture more of the upside after the price target is met).
Entry price: If you act at the close of the day, you can leave this value as 0 and it will take the close of the day for the initial protective stop-loss calculation. You can choose to add a value such as the pattern boundary and in that case it will subtract the initial protective stop-loss from the pattern boundary and not the close of the day. If you use a scaling in tactic during the day (buying in tranches intraday as the breakout takes place) and your average purchase price is different than the close of the day, you can also plug that number in to calculate the initial protective stop-loss.
ATR period: You can select the ATR period. It can be 10 day, 14 day or 30 day or any ATR period of your choice.
ATR Multiplier for Stop-loss: This is the multiplier that you want to trail the price with. From the highest level price reached it will trail the price with a 3 x ATR () distance. The higher the number, the wider the trailing stop-loss. A multiplier of 1 will trail the price so close that and adverse movement can result in triggering the stop-loss.
Custom Value for First day Trailing Stop: This is my favorite part. For aggressive risk management, your initial protective stop can be smaller than what the ATR Trailing Stop will use in its calculation after entry day. In this case you can take 1xATR () or even with FX and Futures you can apply 0.5xATR() as the first day to calculate initial protective stop. The protective stop turns into a trailing stop after the first day.
Entry price: If you act at the close of the day, you can leave this value as 0 and it will take the close of the day for the initial protective stop-loss calculation. You can choose to add a value such as the pattern boundary and in that case it will subtract the initial protective stop-loss from the pattern boundary and not the close of the day. If you use a scaling in tactic during the day (buying in tranches intraday as the breakout takes place) and your average purchase price is different than the close of the day, you can also plug that number in to calculate the initial protective stop-loss.
ATR period: You can select the ATR period. It can be 10 day, 14 day or 30 day or any ATR period of your choice.
ATR Multiplier for Stop-loss: This is the multiplier that you want to trail the price with. From the highest level price reached it will trail the price with a 3 x ATR () distance. The higher the number, the wider the trailing stop-loss. A multiplier of 1 will trail the price so close that and adverse movement can result in triggering the stop-loss.
Custom Value for First day Trailing Stop: This is my favorite part. For aggressive risk management, your initial protective stop can be smaller than what the ATR Trailing Stop will use in its calculation after entry day. In this case you can take 1xATR () or even with FX and Futures you can apply 0.5xATR() as the first day to calculate initial protective stop. The protective stop turns into a trailing stop after the first day.
Script de código aberto
No verdadeiro espirito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam entendê-lo e verificá-lo. Parabéns ao autor Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações e regida pelas Regras da Casa.
Aksel Kibar, CMT
Aviso legal
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.
Script de código aberto
No verdadeiro espirito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam entendê-lo e verificá-lo. Parabéns ao autor Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações e regida pelas Regras da Casa.
Aksel Kibar, CMT
Aviso legal
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.