adolgov

Stepped trailing strategy example

14843 visningar
1174
This is a stepped trailing exit example for educational purpose.

Short brief.
There are 1 stop loss and 3 profit levels.
  • When first tp is reached we move stop loss to break-even.
  • When second tp is reached we move stop loss to first tp.
  • When third tp is reached we exit by profit.
Release Notes: Stop Loss & Take Profit in %% for independence from instrument's tick size.
Release Notes: New input `activateTrailingOnThirdStep` added.
With `activateTrailingOnThirdStep = true` when tp2 will be reached, the strategy places trailing stop with amount at tp3 level and offset at tp2 level.
By default the old behavior remains.
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Kommentarer

500 coins
+7 Svara
500 coins
+1 Svara
great work and have searched long time and no luck until see your work. keep it up! I have implemented your code in my own strategies. Tks
100 coins
Svara
So nice script!

Abusing your knowledge a bit, could you do something like this in a study version and with % instead of points?

It would be magnificent.
+18 Svara
Feature request: Could you please add the option to close half of the position once TP1 is reached?
Thanks a lot
+3 Svara
adolgov Daveatt
@Daveatt, I will try.
+4 Svara
@Daveatt, I have been trying to think of the same thing but can't seem to find a solution, I'm just a pleb.
Svara
This publication is now featured in our Editors' Picks: https://www.tradingview.com/scripts/editors-picks/ .
In the name of all TradingView traders, thank you for your valuable contribution to the TradingView community, and congrats!
+2 Svara
Really nice, clean and usefull script!!

Too bad the "strategy" commands don't work in studies, this would be so helpfull and avoid a lot of unneccesary coding and keeping track of variables.

Good job!

Gr, JD.
+2 Svara
adolgov Duyck
@Duyck, the `strategy` can all things that `study` can )
+1 Svara
Hem Aktie-screener Forex-screener Krypto-screener Ekonomisk kalender Om Diagramfunktioner Priser Tipsa en vän Ordningsregler Hjälpcenter Webbsidor och mäklarlösningar Widgets Diagramlösningar Lightweight Charting Library Blogg och nyheter Twitter