Peter_O

TrailingTakeProfit example

Quite recently I came upon a concept of Trailing Take Profit and I couldn't find a PineScript which implements it for the fastest possible execution, so here it is :)

Everybody knows Trailing StopLoss - an invisible mechanism follows the price and exits the trade once the price retreats too much from its recent most extended favourable value. Trailing TakeProfit does the similar thing, but at the opposite end - the trade gets closed if a price moves too well, in too favourable extent.

Why close the trade if it is going so good? Well, whatever goes up, must go down and vice versa. It is expected, that after fast rally a market will soon fall and after a dump it will go up. So Trailing TakeProfit's role is to secure profits.

But how does Trailing TakeProfit differ from the standard one? "Trailing" means, the exit level is moving. Its role is to be executed only after a rapid favourable move within 1-2 candles, not more. We never know when a rapid move happens, but when it does, we wanna catch those pips and quickly exit without looking back.

Visually Trailing TakeProfit levels are... bands. In this script example these are ATR multiplied bands (aka Keltner Channel), but they could also be Bollinger Bands or something else.

The code is simple just to focus on this single functionality, so you can quickly copy-paste it into your script. Entries are triggered by default SMA crosses.

P.S. I wouldn't be myself, if I didn't add alert messages compatible with the syntax of recently revamped TradingConnector - both in the code already and in the table showing them.

I auto-execute TradingView Alerts into MT4/MT5 using this: www.tradingconnector.com 1-second delivery. Ping me if you need support with installation.
Mã nguồn mở

Với tinh thần TradingView, tác giả của tập lệnh này đã xuất bản nó dưới dạng mã nguồn mở, vì vậy các nhà giao dịch có thể hiểu và xác minh nó. Chúc mừng tác giả! Bạn có thể sử dụng mã này miễn phí, nhưng việc sử dụng lại mã này trong một ấn phẩm chịu sự điều chỉnh của Nội quy nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?