ATR Stop-Loss & Targets

This indicator combines Average True Range (ATR) and Supertrend logic to help traders define precise stop-loss, first target, and trailing stop-loss (TSL) levels.
⚙️ Key Features:
📏 ATR-based Stop-Loss & Target Lines:
Uses ATR (default period: 5) based on the previous day's candle for more stable risk management.
- Traders can choose the price source: Close, Open, or enter a manual price.
- SL and first target are calculated using multipliers:
Multiplier 1 = Stop Loss
Multiplier 2 = First Target
- 📉 Supertrend for Trailing Stop:
- Built-in Supertrend logic for trailing stop-loss management.
Uses ATR(10) with a multiplier of 2.1, based on HL2.
Supertrend can be toggled ON/OFF from the settings.
It is designed to help traders quickly determine:
- Optimal Stop-Loss and Target levels based on volatility (ATR)
- Correct position size based on maximum loss they can afford
- Dynamic trailing stop-loss using a Supertrend
⚙️ How It Works:
1️⃣ ATR-Based Stop-Loss and Target Levels
- The indicator calculates ATR (Average True Range) with a default period of 5.
- You can choose if ATR is calculated based on the current candle or the previous candle.
- Two multipliers are applied:
- Multiplier 1: For Stop-Loss
- Multiplier 2: For First Target
Input Options Available:
- Price Source: Choose from Close, Open, or manually enter a custom price. Default value is Close
- ATR Source Candle: Select Current or Previous. Default is Previous candle
- ATR Period: Default is 5 (modifiable).
- Multipliers: Set your desired levels for Stop-Loss and Target individually.
✨ Visualization:
- Horizontal lines are drawn for both Stop-Loss and First Target levels.
- Color and style of the lines are customizable (solid, dashed, dotted).
- Labels at the end of each line show exact price values.
2️⃣ Maximum Loss Control (Position Size Calculation)
- You can input a Max Loss Amount (default: 10,000).
- The system automatically calculates:
- Risk per share = difference between entry price and stop-loss.
- Position Size = (Max Loss) ÷ (Risk per share).
- Actual Calculated Loss = (Position Size × Risk per share).
✨ Visualization:
- A floating label below the candles displays:
- Position Size (rounded to nearest whole number)
- Actual Calculated Loss (based on real size, not estimation)
- Toggle ON/OFF the label using settings.
3️⃣ Supertrend Trailing Stop-Loss
- Built-in Supertrend using:
ATR Period = 10
ATR Multiplier = 2.1
Source = HL2 (High + Low / 2)
- You can choose to:
Enable or disable Supertrend
Highlight background based on trend direction
Show Buy/Sell Signals
- Alerts are available when Supertrend switches direction.
✨ Visualization:
- Uptrend = Green Supertrend Line
- Downtrend = Orange Supertrend Line
- Optional: Highlight background colors depending on trend.
It is designed to help traders quickly determine:
- Optimal Stop-Loss and Target levels based on volatility (ATR)
- Correct position size based on maximum loss they can afford
- Dynamic trailing stop-loss using a Supertrend
⚙️ How It Works:
1️⃣ ATR-Based Stop-Loss and Target Levels
- The indicator calculates ATR (Average True Range) with a default period of 5.
- You can choose if ATR is calculated based on the current candle or the previous candle.
- Two multipliers are applied:
- Multiplier 1: For Stop-Loss
- Multiplier 2: For First Target
Input Options Available:
- Price Source: Choose from Close, Open, or manually enter a custom price. Default value is Close
- ATR Source Candle: Select Current or Previous. Default is Previous candle
- ATR Period: Default is 5 (modifiable).
- Multipliers: Set your desired levels for Stop-Loss and Target individually.
✨ Visualization:
- Horizontal lines are drawn for both Stop-Loss and First Target levels.
- Color and style of the lines are customizable (solid, dashed, dotted).
- Labels at the end of each line show exact price values.
2️⃣ Maximum Loss Control (Position Size Calculation)
- You can input a Max Loss Amount (default: 10,000).
- The system automatically calculates:
- Risk per share = difference between entry price and stop-loss.
- Position Size = (Max Loss) ÷ (Risk per share).
- Actual Calculated Loss = (Position Size × Risk per share).
✨ Visualization:
- A floating label below the candles displays:
- Position Size (rounded to nearest whole number)
- Actual Calculated Loss (based on real size, not estimation)
- Toggle ON/OFF the label using settings.
3️⃣ Supertrend Trailing Stop-Loss
- Built-in Supertrend using:
ATR Period = 10
ATR Multiplier = 2.1
Source = HL2 (High + Low / 2)
- You can choose to:
Enable or disable Supertrend
Highlight background based on trend direction
Show Buy/Sell Signals
- Alerts are available when Supertrend switches direction.
✨ Visualization:
- Uptrend = Green Supertrend Line
- Downtrend = Orange Supertrend Line
- Optional: Highlight background colors depending on trend.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Untuk akses pantas pada carta, tambah skrip ini kepada kegemaran anda — ketahui lebih lanjut di sini.
Penafian
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Untuk akses pantas pada carta, tambah skrip ini kepada kegemaran anda — ketahui lebih lanjut di sini.