OPEN-SOURCE SCRIPT
Market Volatility Index

Market Regime: Pivot Density + Efficiency + ATR Compression
A market regime detection tool designed to help identify whether price is currently behaving more like a trending market, ranging market, or transitioning environment.
Rather than relying on a single metric, this indicator combines three independent market behavior measurements into a weighted composite score:
• Pivot Density
• Price Efficiency Ratio
• ATR Compression/Expansion
The goal is to provide context before entering trades so you can better align strategy selection with current market conditions.
How It Works
Pivot Density
Measures how frequently pivot highs and lows occur over a lookback period.
High pivot density:
• More frequent reversals
• More indecision
• More likely ranging/choppy behavior
Low pivot density:
• Cleaner directional movement
• Stronger trends
Efficiency Ratio
Measures:
Net Movement ÷ Total Movement
High efficiency:
• Directional price movement
• Stronger trend behavior
Low efficiency:
• Back-and-forth movement
• Less directional conviction
ATR Compression / Expansion
Measures current volatility relative to historical volatility.
ATR compressed:
• Volatility contraction
• Common during ranges or consolidation
ATR expanded:
• Increasing volatility
• Common during stronger directional movement
Composite Regime Score
The three components are combined into a weighted score:
0 → Strong Trend Environment
1 → Strong Range Environment
Default interpretation:
🟢 Trend Zone
Range Score ≤ Trend Threshold
🟡 Transition Zone
Between thresholds
🔴 Range Zone
Range Score ≥ Range Threshold
Background Colors
Green Background
• Trending conditions
• Lower pivot density
• Higher efficiency
• Expanding volatility
Yellow Background
• Mixed or transitional conditions
Red Background
• Choppy/ranging conditions
• Higher pivot density
• Lower efficiency
• Volatility compression
Inputs
Timeframe
Calculation Timeframe
Allows calculations from an alternate timeframe while remaining on the current chart.
Wait Until Bar Close
Uses confirmed higher timeframe values to reduce intrabar fluctuations and maintain consistency.
Pivot Density
Pivot Length
Controls pivot sensitivity.
Lower values:
• More pivots
• Faster response
Higher values:
• Fewer pivots
• Smoother behavior
Pivot Lookback
Number of bars used for pivot density calculations.
Efficiency
Efficiency Length
Controls how far back directional efficiency is measured.
Lower values:
• Faster reactions
Higher values:
• More smoothing
ATR Compression
ATR Length
Length used for current volatility calculations.
ATR Baseline Length
Historical volatility average used for comparison.
Weighting
Adjust contribution of:
• Pivot Density
• Efficiency
• ATR Compression
Increasing a weight causes that component to have greater influence on the final regime score.
Potential Uses
✓ Trend-following strategy filter
✓ Mean reversion strategy filter
✓ Avoiding choppy conditions
✓ Volatility regime detection
✓ Multi-timeframe market context
✓ Strategy optimization
Notes
This indicator is intended as an environment and context tool rather than a direct buy or sell signal generator.
Market regimes constantly evolve, and understanding whether conditions favor trend continuation or mean reversion can help improve decision-making.
Best used alongside:
• Market structure
• Trend tools
• Volume analysis
• Entry and risk management systems
About TrendGenY Indicators
TrendGenY indicators are built from market experience, creative concepts, and a constant pursuit of unique perspectives. Rather than following conventional ideas, the focus is on uncovering alternative insights and viewing market behavior through different angles to reveal information that traditional tools may overlook and help traders build a more meaningful edge in the market.
A market regime detection tool designed to help identify whether price is currently behaving more like a trending market, ranging market, or transitioning environment.
Rather than relying on a single metric, this indicator combines three independent market behavior measurements into a weighted composite score:
• Pivot Density
• Price Efficiency Ratio
• ATR Compression/Expansion
The goal is to provide context before entering trades so you can better align strategy selection with current market conditions.
How It Works
Pivot Density
Measures how frequently pivot highs and lows occur over a lookback period.
High pivot density:
• More frequent reversals
• More indecision
• More likely ranging/choppy behavior
Low pivot density:
• Cleaner directional movement
• Stronger trends
Efficiency Ratio
Measures:
Net Movement ÷ Total Movement
High efficiency:
• Directional price movement
• Stronger trend behavior
Low efficiency:
• Back-and-forth movement
• Less directional conviction
ATR Compression / Expansion
Measures current volatility relative to historical volatility.
ATR compressed:
• Volatility contraction
• Common during ranges or consolidation
ATR expanded:
• Increasing volatility
• Common during stronger directional movement
Composite Regime Score
The three components are combined into a weighted score:
0 → Strong Trend Environment
1 → Strong Range Environment
Default interpretation:
🟢 Trend Zone
Range Score ≤ Trend Threshold
🟡 Transition Zone
Between thresholds
🔴 Range Zone
Range Score ≥ Range Threshold
Background Colors
Green Background
• Trending conditions
• Lower pivot density
• Higher efficiency
• Expanding volatility
Yellow Background
• Mixed or transitional conditions
Red Background
• Choppy/ranging conditions
• Higher pivot density
• Lower efficiency
• Volatility compression
Inputs
Timeframe
Calculation Timeframe
Allows calculations from an alternate timeframe while remaining on the current chart.
Wait Until Bar Close
Uses confirmed higher timeframe values to reduce intrabar fluctuations and maintain consistency.
Pivot Density
Pivot Length
Controls pivot sensitivity.
Lower values:
• More pivots
• Faster response
Higher values:
• Fewer pivots
• Smoother behavior
Pivot Lookback
Number of bars used for pivot density calculations.
Efficiency
Efficiency Length
Controls how far back directional efficiency is measured.
Lower values:
• Faster reactions
Higher values:
• More smoothing
ATR Compression
ATR Length
Length used for current volatility calculations.
ATR Baseline Length
Historical volatility average used for comparison.
Weighting
Adjust contribution of:
• Pivot Density
• Efficiency
• ATR Compression
Increasing a weight causes that component to have greater influence on the final regime score.
Potential Uses
✓ Trend-following strategy filter
✓ Mean reversion strategy filter
✓ Avoiding choppy conditions
✓ Volatility regime detection
✓ Multi-timeframe market context
✓ Strategy optimization
Notes
This indicator is intended as an environment and context tool rather than a direct buy or sell signal generator.
Market regimes constantly evolve, and understanding whether conditions favor trend continuation or mean reversion can help improve decision-making.
Best used alongside:
• Market structure
• Trend tools
• Volume analysis
• Entry and risk management systems
About TrendGenY Indicators
TrendGenY indicators are built from market experience, creative concepts, and a constant pursuit of unique perspectives. Rather than following conventional ideas, the focus is on uncovering alternative insights and viewing market behavior through different angles to reveal information that traditional tools may overlook and help traders build a more meaningful edge in the market.
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。