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.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.