OPEN-SOURCE SCRIPT
Range Bar Gaps Detector

Range Bar Gaps Detector
Overview
The Range Bar Gaps Detector identifies price gaps across multiple range bar sizes (12, 24, 60, and 120) on any trading instrument, helping traders spot potential support/resistance zones or breakout opportunities. Designed for Pine Script v6, this indicator detects gaps on range bars and exports data for use in companion scripts like Range Bar Gaps Overlap, making it ideal for multi-timeframe gap analysis.
Key Features
Multi-Range Gap Detection: Identifies gaps on 12, 24, 60, and 120-range bars, capturing both bullish (gap up) and bearish (gap down) price movements.
Customizable Sensitivity: Includes a user-defined minimum deviation (default: 10% of 14-period SMA) for 12-range gaps to filter out noise.
7-Day Lookback: Automatically prunes gaps older than 7 days to focus on recent, relevant price levels.
Data Export: Serializes up to 10 gaps per range (tops, bottoms, start bars, highest/lowest prices, and age) for seamless integration with overlap analysis scripts.
Debugging Support: Plots gap counts and aggregation data in the Data Window for easy verification of detected gaps.
How It Works
The indicator aggregates price movements to simulate higher range bars (24, 60, 120) from a base range bar chart. It detects gaps when the price jumps significantly between bars, ensuring gaps meet the minimum deviation threshold for 12-range bars. Gaps are stored in arrays, serialized for external use, and pruned after 7 days to maintain efficiency.
Usage
Add to your range bar chart (e.g., 12-range) to detect gaps across multiple ranges.
Use alongside the Range Bar Gaps Overlap indicator to visualize gaps and their overlaps as boxes on the chart.
Check the Data Window to confirm gap counts and sizes for each range (12, 24, 60, 120).
Adjust the "Minimal Deviation (%) for 12-Range" input to control gap detection sensitivity.
Settings
Minimal Deviation (%) for 12-Range: Set the minimum gap size for 12-range bars (default: 10% of 14-period SMA).
Range Sizes: Fixed at 24, 60, and 120 for higher range bar aggregation.
Notes
Ensure the script is published under your TradingView username (e.g., GreenArrow2005) for use with companion scripts.
Best used on range bar charts to maintain consistent gap detection.
For advanced overlap analysis, pair with the Range Bar Gaps Overlap indicator to highlight zones where gaps from different ranges align.
Ideal For
Traders seeking to identify key price levels for support/resistance or breakout strategies.
Multi-timeframe analysts combining gap data across various range bar sizes.
Developers building custom indicators that leverage gap data for advanced charting.
Overview
The Range Bar Gaps Detector identifies price gaps across multiple range bar sizes (12, 24, 60, and 120) on any trading instrument, helping traders spot potential support/resistance zones or breakout opportunities. Designed for Pine Script v6, this indicator detects gaps on range bars and exports data for use in companion scripts like Range Bar Gaps Overlap, making it ideal for multi-timeframe gap analysis.
Key Features
Multi-Range Gap Detection: Identifies gaps on 12, 24, 60, and 120-range bars, capturing both bullish (gap up) and bearish (gap down) price movements.
Customizable Sensitivity: Includes a user-defined minimum deviation (default: 10% of 14-period SMA) for 12-range gaps to filter out noise.
7-Day Lookback: Automatically prunes gaps older than 7 days to focus on recent, relevant price levels.
Data Export: Serializes up to 10 gaps per range (tops, bottoms, start bars, highest/lowest prices, and age) for seamless integration with overlap analysis scripts.
Debugging Support: Plots gap counts and aggregation data in the Data Window for easy verification of detected gaps.
How It Works
The indicator aggregates price movements to simulate higher range bars (24, 60, 120) from a base range bar chart. It detects gaps when the price jumps significantly between bars, ensuring gaps meet the minimum deviation threshold for 12-range bars. Gaps are stored in arrays, serialized for external use, and pruned after 7 days to maintain efficiency.
Usage
Add to your range bar chart (e.g., 12-range) to detect gaps across multiple ranges.
Use alongside the Range Bar Gaps Overlap indicator to visualize gaps and their overlaps as boxes on the chart.
Check the Data Window to confirm gap counts and sizes for each range (12, 24, 60, 120).
Adjust the "Minimal Deviation (%) for 12-Range" input to control gap detection sensitivity.
Settings
Minimal Deviation (%) for 12-Range: Set the minimum gap size for 12-range bars (default: 10% of 14-period SMA).
Range Sizes: Fixed at 24, 60, and 120 for higher range bar aggregation.
Notes
Ensure the script is published under your TradingView username (e.g., GreenArrow2005) for use with companion scripts.
Best used on range bar charts to maintain consistent gap detection.
For advanced overlap analysis, pair with the Range Bar Gaps Overlap indicator to highlight zones where gaps from different ranges align.
Ideal For
Traders seeking to identify key price levels for support/resistance or breakout strategies.
Multi-timeframe analysts combining gap data across various range bar sizes.
Developers building custom indicators that leverage gap data for advanced charting.
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.