OPEN-SOURCE SCRIPT
RTH Gap Fill Statistics

This description is optimized for your RTH Gap Fill Statistics (Full Session) indicator. While your previous script focused on the 12:00 PM cutoff, this version provides a comprehensive view of how gaps behave across the entire Regular Trading Hours (RTH) session.
RTH Gap Fill Statistics [Full Session Probability]
The RTH Gap Fill Statistics indicator is a quantitative analysis tool designed to track the lifecycle of price gaps from the opening bell to the final minutes of the trading day. By analyzing a rolling 126-day sample (approximately 6 months of market data), it provides traders with the historical probability of a gap being filled partially (50%) or fully (100%) before the market close.
This tool is indispensable for intraday traders who need to decide whether a morning gap represents a "Breakaway Gap" (high probability of continuation) or a "Pro Gap" (high probability of a fill).
Core Metrics & Methodology
The script identifies the "Gap" as the distance between the previous day's 4:00 PM close and today's 09:30 AM open. It then monitors every price tick during the RTH session to record the maximum "Fill" achieved.
Gap Up Logic: If price opens above the previous close, a "Fill" is recorded as price moves down toward the previous day's high/close.
Gap Down Logic: If price opens below the previous close, a "Fill" is recorded as price moves up toward the previous day's low/close.
The Probability Matrix (Dashboard)
The dashboard categorizes market behavior into Size Tiers (from micro-gaps of <0.2% to significant gaps >0.8%) to show how size affects the outcome:
Min 50%: The frequency with which price retraced at least half of the opening gap.
100% (Full Fill): The frequency with which price touched the previous day's closing price, completely "closing" the window.
<50%/None: The frequency with which the gap was strongly defended, resulting in less than a 50% retracement.
N: The total sample size (number of days) for that specific gap tier.
How to Interpret the Data
High-Conviction Trends: If a gap tier (e.g., >0.8%) shows a very high percentage in the <50%/None column, it indicates a "Runaway Gap" regime. Fading these moves is statistically dangerous.
Mean Reversion Opportunities: Small gaps (0.2% or less) often exhibit high 100% Fill rates. If the dashboard shows an 80% full-fill rate for small gaps, a move back to the previous day's close is a high-probability trade.
Full Session Context: Unlike morning-only trackers, this script looks at the Full RTH Tier, accounting for late-afternoon "Power Hour" moves that often complete gap fills that were stalled during the midday doldrums.
Technical Specifications
Lookback Period: 126 Days (standard institutional lookback for medium-term regimes).
Timezone: Optimized for America/New_York to align with NYSE/NASDAQ exchange hours.
Precision: Calculated on intraday timeframes (1m, 5m, 15m) to capture the exact wick extremes of the day.
Disclaimer: Historical gap statistics provide a baseline of probability. They should be used to gauge risk-to-reward ratios and are most effective when combined with volume analysis and market internals.
RTH Gap Fill Statistics [Full Session Probability]
The RTH Gap Fill Statistics indicator is a quantitative analysis tool designed to track the lifecycle of price gaps from the opening bell to the final minutes of the trading day. By analyzing a rolling 126-day sample (approximately 6 months of market data), it provides traders with the historical probability of a gap being filled partially (50%) or fully (100%) before the market close.
This tool is indispensable for intraday traders who need to decide whether a morning gap represents a "Breakaway Gap" (high probability of continuation) or a "Pro Gap" (high probability of a fill).
Core Metrics & Methodology
The script identifies the "Gap" as the distance between the previous day's 4:00 PM close and today's 09:30 AM open. It then monitors every price tick during the RTH session to record the maximum "Fill" achieved.
Gap Up Logic: If price opens above the previous close, a "Fill" is recorded as price moves down toward the previous day's high/close.
Gap Down Logic: If price opens below the previous close, a "Fill" is recorded as price moves up toward the previous day's low/close.
The Probability Matrix (Dashboard)
The dashboard categorizes market behavior into Size Tiers (from micro-gaps of <0.2% to significant gaps >0.8%) to show how size affects the outcome:
Min 50%: The frequency with which price retraced at least half of the opening gap.
100% (Full Fill): The frequency with which price touched the previous day's closing price, completely "closing" the window.
<50%/None: The frequency with which the gap was strongly defended, resulting in less than a 50% retracement.
N: The total sample size (number of days) for that specific gap tier.
How to Interpret the Data
High-Conviction Trends: If a gap tier (e.g., >0.8%) shows a very high percentage in the <50%/None column, it indicates a "Runaway Gap" regime. Fading these moves is statistically dangerous.
Mean Reversion Opportunities: Small gaps (0.2% or less) often exhibit high 100% Fill rates. If the dashboard shows an 80% full-fill rate for small gaps, a move back to the previous day's close is a high-probability trade.
Full Session Context: Unlike morning-only trackers, this script looks at the Full RTH Tier, accounting for late-afternoon "Power Hour" moves that often complete gap fills that were stalled during the midday doldrums.
Technical Specifications
Lookback Period: 126 Days (standard institutional lookback for medium-term regimes).
Timezone: Optimized for America/New_York to align with NYSE/NASDAQ exchange hours.
Precision: Calculated on intraday timeframes (1m, 5m, 15m) to capture the exact wick extremes of the day.
Disclaimer: Historical gap statistics provide a baseline of probability. They should be used to gauge risk-to-reward ratios and are most effective when combined with volume analysis and market internals.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.