OPEN-SOURCE SCRIPT
Simple Gap Indicator

Title: Simple Gap Indicator
Description: This is a utility script designed to automate the tracking and management of price gaps (also known as "Windows") on the chart. Unlike static drawings, this indicator dynamically monitors open gaps and automatically "closes" them (stops drawing) once price has filled the area, keeping your chart clean and focused on active levels only.
Why Use This Tool? Traders often mark gaps manually, but charts quickly become cluttered with old, invalid levels. This script solves that problem by using an array-based management system to track every open gap in real-time and remove it the moment it is invalidated by price action.
Technical Methodology:
Gap Detection: The script identifies "Full Gaps" where the Low of the current candle is higher than the High of the previous candle (Bullish), or vice versa (Bearish). This indicates a total disconnect in price delivery.
Dynamic Filtering:
ATR Filter: Users can filter out insignificant "noise" gaps by setting a minimum size threshold based on the Average True Range (ATR).
Time Filter: Option to restrict gap detection to specific session hours (e.g., ignoring overnight gaps on 24h charts).
Auto-Closure: The script loops through all active gaps on every new bar. If the current price wick touches an open gap, the box is visually terminated at that specific bar index and removed from the tracking array.
Visuals:
Green Box: Bullish Gap (Support Zone).
Red Box: Bearish Gap (Resistance Zone).
Labels: Optional text displaying the precise Top/Bottom price coordinates of the gap.
How to Use:
Enable "Auto-Close Gap on Retest" to keep your chart clean.
Use the ATR Filter if you are getting too many signals on lower timeframes (e.g., set to 0.5x ATR).
Set alerts for "New Gap" or "Gap Filled" to automate your workflow.
Credits: Calculations based on standard Gap/Window price action theory. Array management logic custom-coded for Pine Script v6.
Description: This is a utility script designed to automate the tracking and management of price gaps (also known as "Windows") on the chart. Unlike static drawings, this indicator dynamically monitors open gaps and automatically "closes" them (stops drawing) once price has filled the area, keeping your chart clean and focused on active levels only.
Why Use This Tool? Traders often mark gaps manually, but charts quickly become cluttered with old, invalid levels. This script solves that problem by using an array-based management system to track every open gap in real-time and remove it the moment it is invalidated by price action.
Technical Methodology:
Gap Detection: The script identifies "Full Gaps" where the Low of the current candle is higher than the High of the previous candle (Bullish), or vice versa (Bearish). This indicates a total disconnect in price delivery.
Dynamic Filtering:
ATR Filter: Users can filter out insignificant "noise" gaps by setting a minimum size threshold based on the Average True Range (ATR).
Time Filter: Option to restrict gap detection to specific session hours (e.g., ignoring overnight gaps on 24h charts).
Auto-Closure: The script loops through all active gaps on every new bar. If the current price wick touches an open gap, the box is visually terminated at that specific bar index and removed from the tracking array.
Visuals:
Green Box: Bullish Gap (Support Zone).
Red Box: Bearish Gap (Resistance Zone).
Labels: Optional text displaying the precise Top/Bottom price coordinates of the gap.
How to Use:
Enable "Auto-Close Gap on Retest" to keep your chart clean.
Use the ATR Filter if you are getting too many signals on lower timeframes (e.g., set to 0.5x ATR).
Set alerts for "New Gap" or "Gap Filled" to automate your workflow.
Credits: Calculations based on standard Gap/Window price action theory. Array management logic custom-coded for Pine Script v6.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.