OPEN-SOURCE SCRIPT
Volatility Regime Detector [Rider Algo]

Rider Algo - Volatility Regime Detector classifies market conditions into three distinct volatility regimes, helping traders understand WHAT type of market they are facing before deciding HOW to trade it. Think of it as a weather forecast for the market: it tells you whether conditions are calm, trending, or chaotic — so you can choose the right strategy for the moment.
═══════════════════════════════════════════════════════════════════════════
HOW IT WORKS
The indicator combines three independent volatility measurements into a single composite score from 0 to 100:
1. Historical Volatility (40% weight) — Measures how much price is currently moving relative to its recent behavior, using standard deviation of log returns.
2. Bollinger Bandwidth (40% weight) — Tracks how tight or wide the Bollinger Bands are compared to their recent range. Tight bands signal compression; wide bands signal expansion or chaos.
3. Volatility Rate of Change (20% weight) — Measures how quickly volatility itself is accelerating or decelerating, providing early warning of regime shifts.
Each component is normalized to a 0-100 scale and combined into a weighted composite score, smoothed with an EMA to prevent noise.
═══════════════════════════════════════════════════════════════════════════
THE THREE REGIMES
COMPRESSION (Green Zone — Score below threshold)
Volatility is contracting. Price action is tightening into a narrower range. This is often the calm before the storm — a breakout is likely building. This is one of the most actionable regimes: experienced traders use compression phases to prepare entries, set alerts, and position themselves BEFORE the move happens. When you see the panel turn green and the score dropping, start watching for breakout setups.
EXPANSION (Yellow Zone — Score in mid-range)
Volatility is normal and directional. The market is trending and moving with purpose. Standard trend-following strategies tend to work best in this regime.
CHAOS (Red Zone — Score above threshold)
Volatility is extreme and erratic. Price swings are large, unpredictable, and often lack clear direction. This is the danger zone. When the panel turns red, it is a clear warning to exercise extreme caution. Consider reducing position sizes, tightening stops, or stepping aside entirely. Many traders lose money not because they pick the wrong direction, but because they trade full size in chaotic conditions. The red zone exists to help you avoid that mistake.
═══════════════════════════════════════════════════════════════════════════
HOW TO USE IT
The indicator displays as a separate panel below your chart with:
- A colored background that shifts between green, yellow, and red based on the current regime
- A score line (0-100) showing the exact volatility reading
- Subtle threshold lines marking the boundaries between regimes
- Diamond markers at the top of the panel when a regime transition occurs
- A label showing the current regime name and score
Recommended workflow:
1. Check the regime BEFORE entering any trade
2. In GREEN (Compression): Prepare. Scan for breakout setups and set alerts
3. In YELLOW (Expansion): Execute. Use your favorite trend-following tools
4. In RED (Chaos): Protect. Reduce size, tighten stops, or stay flat
═══════════════════════════════════════════════════════════════════════════
INPUTS
- Asset Profile (Auto-Detect / Crypto / Stocks): The indicator automatically detects whether you are trading a high-volatility asset (like BTC) or a lower-volatility asset (like stocks) and adjusts its thresholds accordingly. You can override this manually if needed.
- Sensitivity (Fast / Normal / Slow): Controls the lookback period. Fast reacts quicker to changes; Slow provides smoother, more stable readings.
- Show Score Line: Toggle the numerical score line on or off.
- Alert on Regime Change: Enable built-in alerts that notify you when the market shifts between regimes.
═══════════════════════════════════════════════════════════════════════════
BUILT-IN ALERTS
Four alert conditions are included:
- Regime shifted to Compression
- Regime shifted to Expansion
- Regime shifted to Chaos
- Any Regime Change
═══════════════════════════════════════════════════════════════════════════
TECHNICAL NOTES
- The indicator uses hysteresis buffering at threshold boundaries to prevent rapid flickering between regimes when the score is near a transition point
- Volatility ROC uses sigmoid mapping to prevent extreme outliers from distorting the composite score
- The Auto-Detect feature analyzes ATR as a percentage of price over 50 bars to classify the asset
- All three component scores are available in the Data Window for advanced users who want to see individual readings
- Built in Pine Script v6
═══════════════════════════════════════════════════════════════════════════
PART OF THE RIDER ALGO ECOSYSTEM
This indicator works as a standalone tool, but it is designed to complement the broader Rider Algo suite:
- Use with Rider Algo - Breakout Odds during Compression to estimate breakout probability and direction
- Use with Rider Algo - Moving Average Master during Expansion to follow trends with visual clarity
- Use with Rider Algo - Movement Efficiency during Chaos to filter noise and identify clean moves
The Volatility Regime Detector acts as the strategic layer that helps you decide WHICH tool to prioritize at any given moment.
═══════════════════════════════════════════════════════════════════════════
DISCLAIMER
This indicator is a technical analysis tool designed to classify market volatility conditions. It does NOT provide buy or sell signals, and it does NOT constitute financial, investment, or trading advice of any kind. Past volatility patterns do not guarantee future market behavior. Always conduct your own analysis and consult with a qualified financial advisor before making any trading decisions. Use this tool at your own risk. The author is not responsible for any financial losses incurred from the use of this indicator.
═══════════════════════════════════════════════════════════════════════════
HOW IT WORKS
The indicator combines three independent volatility measurements into a single composite score from 0 to 100:
1. Historical Volatility (40% weight) — Measures how much price is currently moving relative to its recent behavior, using standard deviation of log returns.
2. Bollinger Bandwidth (40% weight) — Tracks how tight or wide the Bollinger Bands are compared to their recent range. Tight bands signal compression; wide bands signal expansion or chaos.
3. Volatility Rate of Change (20% weight) — Measures how quickly volatility itself is accelerating or decelerating, providing early warning of regime shifts.
Each component is normalized to a 0-100 scale and combined into a weighted composite score, smoothed with an EMA to prevent noise.
═══════════════════════════════════════════════════════════════════════════
THE THREE REGIMES
COMPRESSION (Green Zone — Score below threshold)
Volatility is contracting. Price action is tightening into a narrower range. This is often the calm before the storm — a breakout is likely building. This is one of the most actionable regimes: experienced traders use compression phases to prepare entries, set alerts, and position themselves BEFORE the move happens. When you see the panel turn green and the score dropping, start watching for breakout setups.
EXPANSION (Yellow Zone — Score in mid-range)
Volatility is normal and directional. The market is trending and moving with purpose. Standard trend-following strategies tend to work best in this regime.
CHAOS (Red Zone — Score above threshold)
Volatility is extreme and erratic. Price swings are large, unpredictable, and often lack clear direction. This is the danger zone. When the panel turns red, it is a clear warning to exercise extreme caution. Consider reducing position sizes, tightening stops, or stepping aside entirely. Many traders lose money not because they pick the wrong direction, but because they trade full size in chaotic conditions. The red zone exists to help you avoid that mistake.
═══════════════════════════════════════════════════════════════════════════
HOW TO USE IT
The indicator displays as a separate panel below your chart with:
- A colored background that shifts between green, yellow, and red based on the current regime
- A score line (0-100) showing the exact volatility reading
- Subtle threshold lines marking the boundaries between regimes
- Diamond markers at the top of the panel when a regime transition occurs
- A label showing the current regime name and score
Recommended workflow:
1. Check the regime BEFORE entering any trade
2. In GREEN (Compression): Prepare. Scan for breakout setups and set alerts
3. In YELLOW (Expansion): Execute. Use your favorite trend-following tools
4. In RED (Chaos): Protect. Reduce size, tighten stops, or stay flat
═══════════════════════════════════════════════════════════════════════════
INPUTS
- Asset Profile (Auto-Detect / Crypto / Stocks): The indicator automatically detects whether you are trading a high-volatility asset (like BTC) or a lower-volatility asset (like stocks) and adjusts its thresholds accordingly. You can override this manually if needed.
- Sensitivity (Fast / Normal / Slow): Controls the lookback period. Fast reacts quicker to changes; Slow provides smoother, more stable readings.
- Show Score Line: Toggle the numerical score line on or off.
- Alert on Regime Change: Enable built-in alerts that notify you when the market shifts between regimes.
═══════════════════════════════════════════════════════════════════════════
BUILT-IN ALERTS
Four alert conditions are included:
- Regime shifted to Compression
- Regime shifted to Expansion
- Regime shifted to Chaos
- Any Regime Change
═══════════════════════════════════════════════════════════════════════════
TECHNICAL NOTES
- The indicator uses hysteresis buffering at threshold boundaries to prevent rapid flickering between regimes when the score is near a transition point
- Volatility ROC uses sigmoid mapping to prevent extreme outliers from distorting the composite score
- The Auto-Detect feature analyzes ATR as a percentage of price over 50 bars to classify the asset
- All three component scores are available in the Data Window for advanced users who want to see individual readings
- Built in Pine Script v6
═══════════════════════════════════════════════════════════════════════════
PART OF THE RIDER ALGO ECOSYSTEM
This indicator works as a standalone tool, but it is designed to complement the broader Rider Algo suite:
- Use with Rider Algo - Breakout Odds during Compression to estimate breakout probability and direction
- Use with Rider Algo - Moving Average Master during Expansion to follow trends with visual clarity
- Use with Rider Algo - Movement Efficiency during Chaos to filter noise and identify clean moves
The Volatility Regime Detector acts as the strategic layer that helps you decide WHICH tool to prioritize at any given moment.
═══════════════════════════════════════════════════════════════════════════
DISCLAIMER
This indicator is a technical analysis tool designed to classify market volatility conditions. It does NOT provide buy or sell signals, and it does NOT constitute financial, investment, or trading advice of any kind. Past volatility patterns do not guarantee future market behavior. Always conduct your own analysis and consult with a qualified financial advisor before making any trading decisions. Use this tool at your own risk. The author is not responsible for any financial losses incurred from the use of this indicator.
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
Regards,
Trend Rider
Trend Rider
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
Regards,
Trend Rider
Trend Rider
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน