OPEN-SOURCE SCRIPT
ATR Stop Lines

ATR Stop Lines
Plots dynamic stop-loss levels on the price chart based on ATR (Average True Range). Optionally adjusts stop distance based on volatility regime.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎯 WHAT IT DOES
Lines move with price and volatility. When regime-adjust is enabled, stop distance widens in high volatility and tightens in low volatility.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📐 REGIME-ADJUSTED MULTIPLIERS
When enabled, the multiplier auto-adjusts based on the ATR percentile:
Disable regime-adjust to use a fixed multiplier for all conditions.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📈 HOW TO USE
Entry: Note stop line level when entering a trade. Set stop-loss at or beyond that level.
Trailing: Move stop to new line level as price advances in your favor.
Sizing: Wider stop = smaller position to maintain constant risk.
Example:
BTC Daily, ATR = \$2,000, Regime = HIGH (2.0×)
Entry: \$50,000 → Long stop: \$46,000 / Short stop: \$54,000
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 STATUS LABEL
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚙️ SETTINGS
ATR Settings:
Timeframe:
Stop Settings:
Display:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔔 ALERTS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
💡 COMPANION INDICATOR
Use with ATR Volatility Regime (separate pane) for full context:
Both use identical ATR/percentile logic and stay in sync.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📝 NOTES
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🏷️ TAGS
ATR, stop-loss, volatility, risk-management, position-sizing, trailing-stop, swing-trading
Plots dynamic stop-loss levels on the price chart based on ATR (Average True Range). Optionally adjusts stop distance based on volatility regime.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎯 WHAT IT DOES
- Green line — Long stop (Close − ATR × multiplier)
- Red line — Short stop (Close + ATR × multiplier)
Lines move with price and volatility. When regime-adjust is enabled, stop distance widens in high volatility and tightens in low volatility.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📐 REGIME-ADJUSTED MULTIPLIERS
When enabled, the multiplier auto-adjusts based on the ATR percentile:
- LOW (< 25th pctl) — 1.0× ATR — Tight stops, small moves expected
- NORMAL (25–50th pctl) — 1.5× ATR — Standard distance
- HIGH (50–75th pctl) — 2.0× ATR — Wider to avoid noise
- EXTREME (> 75th pctl) — 2.5× ATR — Widest, or skip the trade
Disable regime-adjust to use a fixed multiplier for all conditions.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📈 HOW TO USE
Entry: Note stop line level when entering a trade. Set stop-loss at or beyond that level.
Trailing: Move stop to new line level as price advances in your favor.
Sizing: Wider stop = smaller position to maintain constant risk.
Example:
BTC Daily, ATR = \$2,000, Regime = HIGH (2.0×)
Entry: \$50,000 → Long stop: \$46,000 / Short stop: \$54,000
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 STATUS LABEL
- VOL — Current regime (LOW / NORMAL / HIGH / EXTREME)
- ATR — Raw ATR value in price units
- Mult — Active multiplier
- Stop Dist — Current stop distance in price units
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚙️ SETTINGS
ATR Settings:
- ATR Length (default: 14)
- Percentile Lookback (default: 100)
Timeframe:
- Use Fixed Timeframe — Lock to specific TF
- Fixed Timeframe (default: D)
Stop Settings:
- Regime-Adjusted Multiplier — Toggle auto-adjust on/off
- Base ATR Multiplier — Used when regime-adjust is off
- LOW/NORMAL/HIGH/EXTREME Multipliers — Customize per regime
Display:
- Show Long Stop / Show Short Stop
- Show Status Label
- Long/Short Stop Colors
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔔 ALERTS
- Vol → EXTREME
- Vol → LOW
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
💡 COMPANION INDICATOR
Use with ATR Volatility Regime (separate pane) for full context:
- Pane indicator → percentile visualization, zone backgrounds
- This indicator → actionable stop levels on price chart
Both use identical ATR/percentile logic and stay in sync.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📝 NOTES
- Works on any timeframe
- Stops are dynamic — recalculate each bar
- Not a signal generator — use with your own entry logic
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🏷️ TAGS
ATR, stop-loss, volatility, risk-management, position-sizing, trailing-stop, swing-trading
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน