OPEN-SOURCE SCRIPT
ATR Volatility Regime

ATR Volatility Regime
A volatility classification indicator that uses ATR (Average True Range) percentile ranking to identify LOW, NORMAL, HIGH, or EXTREME volatility conditions.
Displayed as a separate pane oscillator (0–100 scale) with colored zones.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
💡 WHY THIS INDICATOR?
Most volatility indicators show raw ATR — a number without context. Is ATR = 50 high or low? Depends on the asset and recent history.
This indicator answers: "Is current volatility high or low for THIS asset, right now?"
What it adds over standard ATR:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📐 CORE CONCEPTS
ATR (Average True Range)
Measures volatility in price units — how much an asset typically moves per bar. Directionless (magnitude only, not direction).
Calculation:
True Range = the greatest of:
ATR = Moving average of True Range over N bars (default: 14)
Percentile Rank (Pctl)
Answers: "What percentage of historical values is the current value greater than?"
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎯 WHAT IT DOES
Classifies current volatility into four regimes:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 DISPLAY COMPONENTS
Oscillator Line (0–100)
ATR percentile rank over time. Color matches regime:
Zone Backgrounds
Colored bands at threshold levels for instant visual reference.
Status Label
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📈 HOW TO USE
LOW Volatility (Pctl < 25%):
NORMAL Volatility (Pctl 25–50%):
HIGH Volatility (Pctl 50–75%):
EXTREME Volatility (Pctl > 75%):
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚙️ SETTINGS
ATR Settings:
Timeframe:
Thresholds:
Display:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📋 SUGGESTED LOOKBACK BY ASSET
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔔 ALERTS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
💡 PRACTICAL APPLICATIONS
Stop-Loss Sizing:
Use raw ATR for stops. Example: Stop = Entry − (1.5 × ATR)
Position Sizing:
Reduce size when percentile is HIGH or EXTREME.
Entry Filtering:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📝 NOTES
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🏷️ TAGS
volatility, ATR, average-true-range, percentile, regime, risk-management, position-sizing, swing-trading, MTF
A volatility classification indicator that uses ATR (Average True Range) percentile ranking to identify LOW, NORMAL, HIGH, or EXTREME volatility conditions.
Displayed as a separate pane oscillator (0–100 scale) with colored zones.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
💡 WHY THIS INDICATOR?
Most volatility indicators show raw ATR — a number without context. Is ATR = 50 high or low? Depends on the asset and recent history.
This indicator answers: "Is current volatility high or low for THIS asset, right now?"
What it adds over standard ATR:
- Percentile context — Compares current ATR to its own history
- Regime classification — Actionable labels instead of raw numbers
- Visual zones — Instant read without interpretation
- Optional MTF — Lock to a fixed timeframe while viewing another
- Auto-adapts — Works on any asset without manual threshold tuning
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📐 CORE CONCEPTS
ATR (Average True Range)
Measures volatility in price units — how much an asset typically moves per bar. Directionless (magnitude only, not direction).
Calculation:
True Range = the greatest of:
- High − Low (current bar's range)
- |High − Previous Close| (gap up captured)
- |Low − Previous Close| (gap down captured)
ATR = Moving average of True Range over N bars (default: 14)
Percentile Rank (Pctl)
Answers: "What percentage of historical values is the current value greater than?"
- Pctl = 0% → Lowest ATR in lookback period (extreme compression)
- Pctl = 50% → Median ATR (typical volatility)
- Pctl = 100% → Highest ATR in lookback period (extreme expansion)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎯 WHAT IT DOES
Classifies current volatility into four regimes:
- LOW (< 25th percentile) — Compression, breakout likely brewing
- NORMAL (25th–50th percentile) — Typical market conditions
- HIGH (50th–75th percentile) — Elevated volatility, use caution
- EXTREME (> 75th percentile) — Rare expansion, tighten stops or stay flat
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 DISPLAY COMPONENTS
Oscillator Line (0–100)
ATR percentile rank over time. Color matches regime:
- Blue = LOW
- Gray = NORMAL
- Orange = HIGH
- Red = EXTREME
Zone Backgrounds
Colored bands at threshold levels for instant visual reference.
Status Label
- VOL — Current regime
- ATR — Raw ATR value (for stop sizing)
- Pctl — Percentile rank (0–100%)
- TF — Active timeframe (chart or fixed)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📈 HOW TO USE
LOW Volatility (Pctl < 25%):
- Market compressed — "calm before the storm"
- Watch for breakout setups
- Pctl = 0% often precedes significant moves
NORMAL Volatility (Pctl 25–50%):
- Typical conditions
- Standard position sizing and stops
HIGH Volatility (Pctl 50–75%):
- Elevated movement — reduce size
- Widen stops to avoid noise
EXTREME Volatility (Pctl > 75%):
- Rare, intense conditions
- Avoid new entries or tighten risk
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚙️ SETTINGS
ATR Settings:
- ATR Length (default: 14) — Period for ATR calculation
- Percentile Lookback (default: 100) — Bars for percentile ranking
Timeframe:
- Use Fixed Timeframe (default: off) — Lock calculation to specific TF
- Fixed Timeframe (default: D) — TF to use when fixed mode enabled
Thresholds:
- Low Threshold (default: 25)
- High Threshold (default: 50)
- Extreme Threshold (default: 75)
Display:
- Show Zone Background — Toggle colored fills
- Show Status Label — Toggle info label
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📋 SUGGESTED LOOKBACK BY ASSET
- Crypto — 100 bars (fast regime shifts)
- Stocks — 252 bars (one trading year)
- Forex — 100–150 bars
- Commodities — 150–200 bars (seasonal patterns)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔔 ALERTS
- Vol → EXTREME
- Vol → HIGH
- Vol → LOW
- Vol exits HIGH
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
💡 PRACTICAL APPLICATIONS
Stop-Loss Sizing:
Use raw ATR for stops. Example: Stop = Entry − (1.5 × ATR)
Position Sizing:
Reduce size when percentile is HIGH or EXTREME.
Entry Filtering:
- LOW regime = prepare for breakout
- EXTREME regime = avoid new entries
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📝 NOTES
- Works on any timeframe — adapts to chart or locks to fixed TF
- ATR is non-directional — magnitude only
- Percentile auto-adapts to each asset's volatility profile
- Not a standalone signal — combine with trend/regime filters
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🏷️ TAGS
volatility, ATR, average-true-range, percentile, regime, risk-management, position-sizing, swing-trading, MTF
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.