OPEN-SOURCE SCRIPT

Trader Marks Trailing SL + TP (Long & Short, mirrored)

103
📌 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.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.