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.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.