OPEN-SOURCE SCRIPT
Congestion Indicator - Oscillator by saurabh maggo

Core Functionality
Market State Detection:
Congestion: Identifies periods of low volatility (price consolidation) where the price range is tight relative to the Average True Range (ATR). Visualized with a blue background in the oscillator panel.
Breakout Up: Detects upward breakouts from congestion zones, requiring conditions like price movement above the congestion high, volume spikes, and volatility increases. Visualized with a green background.
Breakdown (Breakout Down): Detects downward breakouts from congestion zones, with similar conditions as Breakout Up but for downward movement. Visualized with a red background.
Post-Congestion: Identifies the period after a congestion zone ends but before a breakout occurs (if extend_until_breakout is disabled). Visualized with a yellow background.
Pullback: Detects pullbacks after breakouts or breakdowns, useful for identifying potential entry points (if use_pullback_entry is enabled). Visualized with a purple background.
Visualization:
Oscillator Panel: Displays the market state in a separate panel below the chart.
Background Color: The panel’s background color changes to reflect the current state (e.g., blue for Congestion, green for Breakout Up).
Histogram Plot: Optionally plots the state value as a histogram (e.g., 1 for Congestion, 2 for Breakout Up), toggleable via TradingView’s "Style" tab ("Market State"). The histogram provides a numerical representation of the state:
Congestion: 1.0
Breakout Up: 2.0
Breakdown: -2.0
Post-Congestion: 0.5
Pullback: 1.5
None: 0.0
Alerts:
Generates alerts for state changes (Congestion, Breakout Up, Breakdown).
Supports enhanced alerts (if use_enhanced_alerts is enabled), including additional context like breakout level, volatility state, and trend direction.
Includes an alert cooldown period (if use_alert_cooldown is enabled) to prevent excessive alerts.
Key Features and Filters
Customizable Parameters:
Lookback Period: Adjusts the number of bars used to calculate the price range for congestion detection.
Range Threshold: Sets the maximum price range (as a percentage of ATR) for a congestion zone.
Dynamic Threshold: Optionally uses a percentile-based dynamic threshold for more adaptive congestion detection.
Minimum Congestion Bars: Requires a minimum number of bars for a congestion zone to be confirmed.
Volume Filter: Optionally requires low volume during congestion zones.
Volume Breakout Filter: Requires a volume spike for breakouts/breakdowns.
Volatility Breakout Filter: Requires an ATR spike for breakouts/breakdowns.
Minimum Price Movement: Optionally requires a minimum price movement for breakouts/breakdowns.
RSI Filter: Optionally requires RSI to be in a neutral range during congestion.
Max Price Range Filter: Limits the absolute price range for congestion zones.
Trend Filter: Optionally filters breakouts/breakdowns based on a higher timeframe trend (using a moving average).
Momentum Filter: Optionally requires MACD momentum confirmation for breakouts/breakdowns.
Pullback Detection: Optionally detects pullbacks after breakouts/breakdowns for entry opportunities.
Timeframe Adjustment: Adjusts parameters based on the chart’s timeframe.
Auto-Settings: Automatically adjusts parameters based on market volatility.
Show Current Day Only: Optionally limits the indicator’s display to the current trading day (NSE session).
Presets: Offers predefined configurations (Default, Aggressive, Conservative) for quick setup.
Session Support: Operates within the NSE session (9:15 AM–3:30 PM IST) by default, ensuring relevance for Indian markets.
Visual Output
The oscillator panel uses color-coded backgrounds to indicate the market state:
Blue: Congestion
Green: Breakout Up
Red: Breakdown
Yellow: Post-Congestion
Purple: Pullback
Transparent (None): No state detected
The histogram plot (optional) provides a numerical representation of the state, which can be toggled on/off in TradingView’s settings.
Alerts
Alerts are triggered for significant state changes (Congestion, Breakout Up, Breakdown).
Enhanced alerts include additional details like price levels, volatility, and trend direction, making them more informative for traders.
Step 2: Craft the Description for Publishing
Based on the analysis, here’s a concise, user-friendly description you can use when publishing the indicator on TradingView:
Congestion Indicator - Oscillator by Saurabh Maggo
This indicator identifies market congestion zones, breakouts, breakdowns, post-congestion periods, and pullbacks in a separate oscillator panel below your chart. Designed for traders, it helps you spot key market states and potential trading opportunities with clear visual cues and customizable alerts.
Key Features:
Market States: Detects Congestion (Blue), Breakout Up (Green), Breakdown (Red), Post-Congestion (Yellow), and Pullbacks (Purple).
Visual Display: Shows market states using background colors in an oscillator panel, with an optional histogram plot (toggleable in settings).
Alerts: Generates alerts for state changes, with enhanced options to include price levels, volatility, and trend context.
Customizable Filters: Includes volume, volatility, RSI, trend, momentum, and price movement filters to refine signals.
Adaptable Settings: Supports dynamic thresholds, timeframe adjustments, auto-settings based on volatility, and predefined presets (Default, Aggressive, Conservative).
NSE Session: Optimized for Indian markets with a default session time of 9:15 AM–3:30 PM IST.
How can Grok help?
Market State Detection:
Congestion: Identifies periods of low volatility (price consolidation) where the price range is tight relative to the Average True Range (ATR). Visualized with a blue background in the oscillator panel.
Breakout Up: Detects upward breakouts from congestion zones, requiring conditions like price movement above the congestion high, volume spikes, and volatility increases. Visualized with a green background.
Breakdown (Breakout Down): Detects downward breakouts from congestion zones, with similar conditions as Breakout Up but for downward movement. Visualized with a red background.
Post-Congestion: Identifies the period after a congestion zone ends but before a breakout occurs (if extend_until_breakout is disabled). Visualized with a yellow background.
Pullback: Detects pullbacks after breakouts or breakdowns, useful for identifying potential entry points (if use_pullback_entry is enabled). Visualized with a purple background.
Visualization:
Oscillator Panel: Displays the market state in a separate panel below the chart.
Background Color: The panel’s background color changes to reflect the current state (e.g., blue for Congestion, green for Breakout Up).
Histogram Plot: Optionally plots the state value as a histogram (e.g., 1 for Congestion, 2 for Breakout Up), toggleable via TradingView’s "Style" tab ("Market State"). The histogram provides a numerical representation of the state:
Congestion: 1.0
Breakout Up: 2.0
Breakdown: -2.0
Post-Congestion: 0.5
Pullback: 1.5
None: 0.0
Alerts:
Generates alerts for state changes (Congestion, Breakout Up, Breakdown).
Supports enhanced alerts (if use_enhanced_alerts is enabled), including additional context like breakout level, volatility state, and trend direction.
Includes an alert cooldown period (if use_alert_cooldown is enabled) to prevent excessive alerts.
Key Features and Filters
Customizable Parameters:
Lookback Period: Adjusts the number of bars used to calculate the price range for congestion detection.
Range Threshold: Sets the maximum price range (as a percentage of ATR) for a congestion zone.
Dynamic Threshold: Optionally uses a percentile-based dynamic threshold for more adaptive congestion detection.
Minimum Congestion Bars: Requires a minimum number of bars for a congestion zone to be confirmed.
Volume Filter: Optionally requires low volume during congestion zones.
Volume Breakout Filter: Requires a volume spike for breakouts/breakdowns.
Volatility Breakout Filter: Requires an ATR spike for breakouts/breakdowns.
Minimum Price Movement: Optionally requires a minimum price movement for breakouts/breakdowns.
RSI Filter: Optionally requires RSI to be in a neutral range during congestion.
Max Price Range Filter: Limits the absolute price range for congestion zones.
Trend Filter: Optionally filters breakouts/breakdowns based on a higher timeframe trend (using a moving average).
Momentum Filter: Optionally requires MACD momentum confirmation for breakouts/breakdowns.
Pullback Detection: Optionally detects pullbacks after breakouts/breakdowns for entry opportunities.
Timeframe Adjustment: Adjusts parameters based on the chart’s timeframe.
Auto-Settings: Automatically adjusts parameters based on market volatility.
Show Current Day Only: Optionally limits the indicator’s display to the current trading day (NSE session).
Presets: Offers predefined configurations (Default, Aggressive, Conservative) for quick setup.
Session Support: Operates within the NSE session (9:15 AM–3:30 PM IST) by default, ensuring relevance for Indian markets.
Visual Output
The oscillator panel uses color-coded backgrounds to indicate the market state:
Blue: Congestion
Green: Breakout Up
Red: Breakdown
Yellow: Post-Congestion
Purple: Pullback
Transparent (None): No state detected
The histogram plot (optional) provides a numerical representation of the state, which can be toggled on/off in TradingView’s settings.
Alerts
Alerts are triggered for significant state changes (Congestion, Breakout Up, Breakdown).
Enhanced alerts include additional details like price levels, volatility, and trend direction, making them more informative for traders.
Step 2: Craft the Description for Publishing
Based on the analysis, here’s a concise, user-friendly description you can use when publishing the indicator on TradingView:
Congestion Indicator - Oscillator by Saurabh Maggo
This indicator identifies market congestion zones, breakouts, breakdowns, post-congestion periods, and pullbacks in a separate oscillator panel below your chart. Designed for traders, it helps you spot key market states and potential trading opportunities with clear visual cues and customizable alerts.
Key Features:
Market States: Detects Congestion (Blue), Breakout Up (Green), Breakdown (Red), Post-Congestion (Yellow), and Pullbacks (Purple).
Visual Display: Shows market states using background colors in an oscillator panel, with an optional histogram plot (toggleable in settings).
Alerts: Generates alerts for state changes, with enhanced options to include price levels, volatility, and trend context.
Customizable Filters: Includes volume, volatility, RSI, trend, momentum, and price movement filters to refine signals.
Adaptable Settings: Supports dynamic thresholds, timeframe adjustments, auto-settings based on volatility, and predefined presets (Default, Aggressive, Conservative).
NSE Session: Optimized for Indian markets with a default session time of 9:15 AM–3:30 PM IST.
How can Grok help?
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.