OPEN-SOURCE SCRIPT
Trader Marks Trailing SL + TP (Long & Short, mirrored)

📌 Trader Marks Trailing SL + TP (Long & Short, mirrored)
This script implements an advanced trailing stop and take-profit system for both long and short trades.
It combines fixed entry/TP levels with a progressive looping mechanism that dynamically adjusts the trailing stop.
🔑 Key Features
Long & Short mirrored
The script works symmetrically for both long and short setups.
Fixed or percentage-based Take-Profit
You can either set a fixed TP price or have it calculated automatically as entry ± percentage distance.
Progressive Trailing Stop with Looping Mechanism
The stop-loss moves progressively towards the take-profit depending on price development.
For longs, the SL only moves upward (never lower).
For shorts, the SL only moves downward (never higher).
The looping exponent (tightPower) controls how strongly the gap between price and SL “tightens” over time:
Smaller values (e.g. 1.0) → gentle tightening, SL follows loosely.
Larger values (e.g. 3.0) → aggressive tightening, SL closes in on price faster.
Dynamic Minimum Distance
Default: 0.9 % distance from price.
As soon as the stop-loss touches the current or previous candle → automatic switch to 1.5 %.
Once the next candle no longer touches the SL → it reverts back to 0.9 %.
Lock at TP
Option to pull the SL exactly to the TP level once it is reached.
Automatic Reset
If any inputs change (Entry, TP, Trade Direction), the SL can be re-initialized automatically.
🎨 Visualization
Blue line → Entry level
Teal line → Take-profit level
Red line → Dynamic trailing stop
The data window also shows whether the tight mode (1.5 %) is currently active.
This script implements an advanced trailing stop and take-profit system for both long and short trades.
It combines fixed entry/TP levels with a progressive looping mechanism that dynamically adjusts the trailing stop.
🔑 Key Features
Long & Short mirrored
The script works symmetrically for both long and short setups.
Fixed or percentage-based Take-Profit
You can either set a fixed TP price or have it calculated automatically as entry ± percentage distance.
Progressive Trailing Stop with Looping Mechanism
The stop-loss moves progressively towards the take-profit depending on price development.
For longs, the SL only moves upward (never lower).
For shorts, the SL only moves downward (never higher).
The looping exponent (tightPower) controls how strongly the gap between price and SL “tightens” over time:
Smaller values (e.g. 1.0) → gentle tightening, SL follows loosely.
Larger values (e.g. 3.0) → aggressive tightening, SL closes in on price faster.
Dynamic Minimum Distance
Default: 0.9 % distance from price.
As soon as the stop-loss touches the current or previous candle → automatic switch to 1.5 %.
Once the next candle no longer touches the SL → it reverts back to 0.9 %.
Lock at TP
Option to pull the SL exactly to the TP level once it is reached.
Automatic Reset
If any inputs change (Entry, TP, Trade Direction), the SL can be re-initialized automatically.
🎨 Visualization
Blue line → Entry level
Teal line → Take-profit level
Red line → Dynamic trailing stop
The data window also shows whether the tight mode (1.5 %) is currently active.
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。