Gap-Fill Strategy: Trading Base Rates, Not Hopes
Abstract
This strategy identifies and trades daily opening gaps using a base-rate-first methodology: it measures the raw frequency at which gaps close within a specified time window before setting entry rules, identifies conditions where that frequency exceeds the breakeven cost threshold, and enters only those statistically favorable scenarios. By quantifying the prior probability of a gap fill before rule refinement, the approach avoids the common trap of chasing gaps without measuring their actual closure rate.
Why This Might Work
Gap mechanics and overnight discontinuities. Overnight and after-hours trading create price discontinuities at market open. These gaps reflect overnight news, earnings announcements, macroeconomic releases, or simple order imbalance between market close and open [1]. Once continuous trading resumes at the regular session open, price discovery accelerates. Some gaps then close intraday (mean reversion toward the previous close); others persist (new equilibrium or continued momentum in the overnight direction) [2].
The base rate fallacy in gap trading. Many traders notice gaps and assume they "fill back" to the prior close without measuring how often this actually occurs. This is base rate neglect: the well-documented cognitive bias of ignoring the prior probability of an outcome when judging a specific instance [3]. A trader who observes ten gap-fills in a row may conclude the strategy is solid, unaware that those ten may constitute a small non-representative sample from a much larger population with a substantially lower true fill rate.
Base-rate-first methodology. Before adding entry rules (e.g., "trade gaps larger than 1%"), a practitioner should first ask a simpler question: of all gaps observed over 1-2 years of historical data, what percentage close intraday within, say, four hours? If 30% of gaps close within that window, the base rate is 0.30. After subtracting transaction costs (commission, bid-ask spread, slippage), a profitable strategy requires the fill rate to exceed the breakeven threshold. Only if the observed fill rate clears that threshold do entry rules make sense. This discipline eliminates rules built on false positives.
Why fill rates vary by condition. Gap fill rates are not homogeneous; they depend on gap size, direction, instrument volatility, and market regime [2]. Small gaps may revert more reliably than large gaps. Gaps occurring during routine overnight news may have higher fill rates than those coinciding with macroeconomic surprises. By conditioning entry only on high-probability fills and segmenting by gap characteristics, the strategy concentrates capital on regimes where reversion is actually likely, rather than averaging over all gaps and accepting mediocre results.
Practitioner precedent. Gap trading appears in trading forums and practitioner literature, but few sources explicitly measure base-rate fill rates before trading [4]. This strategy formalizes that missing step.
The Rules
Instrument and Timeframe: Liquid stocks or index ETFs (examples: SPY, QQQ, major US equities)
- Daily timeframe: gaps measured at the 9:30 AM ET market open
- Intraday fills checked within the first four hours (9:30 AM to 1:30 PM ET)
Entry Trigger
- At market open, calculate the gap as
(open price − previous close) / previous close - Trade only if:
- Absolute gap magnitude exceeds 0.5% (user-tunable; tested at 0.5%, 1%, 2%)
- AND the historical fill rate for the gap direction (up or down) over the prior 252 trading days exceeds 53%
- The 53% threshold is derived as breakeven after round-trip costs: commission (~0.15%), bid-ask spread (~0.1%), slippage (~0.1%) totaling roughly 0.35% round-trip, implying a minimum profitable fill rate of approximately 50.35%
Entry Execution: Enter at market open (within the first minute of the session)
- Long entry on gaps down (expecting upward reversion); short entry on gaps up (expecting downward reversion)
Initial Stop Loss: If long (gap down, expecting bounce up): place stop 0.20% below the open price
- If short (gap up, expecting fill downward): place stop 0.20% above the open price
- Rationale: a stop placed beyond the gap would be too wide and risk excessive loss; a small stop near the open allows quick exit if the gap extends rather than filling
Exit Strategy: Primary (profit exit): exit when price reaches the previous day's close (gap closes within 0.05%)
- Time stop: if the gap has not closed by 1:30 PM ET (four hours post-open), exit at the market close or at 1:30 PM, whichever comes first
- Stop-loss exit: if the stop-loss price is touched, exit immediately
Position Sizing: Risk a fixed percentage of account equity per trade, typically 1-2%
- Position size = (account equity × risk percentage) / (entry price − stop price)
- Example: $100,000 account, 2% risk per trade, stop 0.20% away: position size = ($100,000 × 0.02) / 0.002 = 1,000 shares (adjusted for the specific instrument)
Session and Time Filters: Trade only during the first four hours of the US regular trading session (9:30 AM to 1:30 PM ET)
- Do not trade if the following day is a US market holiday
- Exclude trades on days when major US economic data (non-farm payroll, FOMC announcement, etc.) is released within two hours of market open, due to elevated volatility and degraded gap-fill statistics
Expected Trade Frequency: A single liquid stock typically experiences a 0.5% or larger gap on 5-10% of trading days
- Across three to five highly liquid instruments, the portfolio generates 30-100 trade opportunities per year
- After applying the base-rate filter (trade only when historical fill rate >53%), the count drops to approximately 15-50 trades per year, depending on gap-size threshold and instrument selection
- This sample size (15-50 trades per year) is at the minimum threshold for meaningful statistical inference; larger samples (100+ trades) are preferable and can be achieved by lowering the gap-size threshold, adding more instruments, or adjusting the fill-rate threshold
//@version=6
strategy("Gap-Fill Base-Rate Strategy", overlay=true,
default_qty_type=strategy.percent_of_equity,
default_qty_value=2.0,
commission_type=strategy.commission.percent,
commission_value=0.0015,
slippage=1)
// === INPUTS ===
gap_threshold = input.float(0.5, "Gap Threshold (%)", minval=0.1, maxval=5.0) / 100.0
lookback_days = input.int(252, "Base Rate Lookback (days)", minval=60, maxval=500)
fill_rate_threshold = input.float(53.0, "Min Fill Rate Threshold (%)", minval=50.0, maxval=70.0) / 100.0
time_window_hours = input.int(4, "Fill Window (hours)", minval=1, maxval=8)
stop_loss_pct = input.float(0.20, "Stop Loss (%)", minval=0.1, maxval=1.0) / 100.0
// === HELPERS ===
in_session() => syminfo.session == session.regular
mins_into_open() => (hour - 9) * 60 + (minute - 30)
in_trade_window() => mins_into_open() >= 0 and mins_into_open() < time_window_hours * 60
// === CURRENT GAP ===
gap_pct = (open - close[1]) / close[1]
// === BASE RATE CALCULATION (recalculate each bar) ===
var float fill_rate_up = 0.0
var float fill_rate_down = 0.0
if barstate.isnew
gaps_up_count = 0
gaps_up_filled = 0
gaps_down_count = 0
gaps_down_filled = 0
// Count historical gaps and fills over lookback period
for i = 1 to math.min(lookback_days, bar_index)
past_gap = (open[i] - close[i + 1]) / close[i + 1]
prev_close = close[i + 1]
if math.abs(past_gap) > gap_threshold
if past_gap > 0 // gap up
gaps_up_count += 1
// Filled if daily low reached previous close (within tolerance)
if low[i] <= prev_close * 1.0005
gaps_up_filled += 1
else // gap down
gaps_down_count += 1
// Filled if daily high reached previous close (within tolerance)
if high[i] >= prev_close * 0.9995
gaps_down_filled += 1
// Compute fill rates
fill_rate_up = gaps_up_count > 0 ? gaps_up_filled / gaps_up_count : 0.0
fill_rate_down = gaps_down_count > 0 ? gaps_down_filled / gaps_down_count : 0.0
// === ENTRY SIGNALS ===
gap_down = gap_pct < -gap_threshold
gap_up = gap_pct > gap_threshold
long_signal = gap_down and (fill_rate_down > fill_rate_threshold) and in_trade_window() and in_session() and strategy.position_size == 0
short_signal = gap_up and (fill_rate_up > fill_rate_threshold) and in_trade_window() and in_session() and strategy.position_size == 0
// === EXITS ===
if long_signal
stop_long = open * (1 - stop_loss_pct)
limit_long = close[1]
strategy.entry("LongGap", strategy.long)
strategy.exit("LongExit", "LongGap", stop=stop_long, limit=limit_long)
if short_signal
stop_short = open * (1 + stop_loss_pct)
limit_short = close[1]
strategy.entry("ShortGap", strategy.short)
strategy.exit("ShortExit", "ShortGap", stop=stop_short, limit=limit_short)
// === TIME-BASED CLOSE ===
if strategy.position_size != 0 and mins_into_open() >= time_window_hours * 60
strategy.close_all()
// === DISPLAY ===
plot(gap_pct * 100, "Gap %", color=color.gray, linewidth=1)
plot(fill_rate_up * 100, "Fill Up %", color=color.blue, linewidth=1)
plot(fill_rate_down * 100, "Fill Down %", color=color.red, linewidth=1)
hline(fill_rate_threshold * 100, "Threshold", color=color.orange, linestyle=hline.dashed)
How the Code Works
Gap calculation. At each candle opening, the code calculates gap_pct = (open − close[1](#ref-1)) / close[1](#ref-1), the percentage move from the previous close to the current open.
Base-rate recalculation. At the start of each new bar (checked with barstate.isnew), the code loops backward through up to 252 prior candles. For each historical candle, it computes the gap that occurred at that bar's open and checks whether the subsequent daily high or low reached back to the previous close (within 0.05%, a small tolerance for rounding). It tallies the total count of gaps in each direction (up and down) and the count of those that filled.
Fill-rate computation. After the loop, the code calculates fill_rate_up and fill_rate_down as the ratio of filled gaps to total gaps in each direction. These are stored in var variables so they persist across bars until recalculated at the next bar open.
Entry conditions. A long entry triggers if a gap-down exists, the historical fill-rate for gap-downs exceeds the user's threshold (default 53%), the current time is within the four-hour trading window, and the strategy has no open position. Short entries trigger symmetrically for gap-ups with sufficient historical fill rate.
Exit orders. The strategy.exit() calls place a stop-loss order at the entry price ±0.20% and a limit order at the previous close (simulating a gap fill). If both orders are live, the first to trigger closes the position.
Time-based close. If a position remains open past the time window (4 hours by default), the code closes it at market price.
Visualization. Plot statements display the current gap percentage and the two fill rates, allowing the user to inspect whether the fill-rate threshold is being met and confirm the code's logic visually.
Testing It Honestly
Base-rate measurement phase. The first step is to measure, not trade. Load 1-2 years of historical daily data for a candidate instrument. Calculate (or use the code's plot) the historical fill rate for gaps of 0.5% or larger in each direction. Record the denominator: how many such gaps occurred over this period? A meaningful sample requires at least 50-100 gap events.
Threshold selection. If the measured gap-down fill rate over 252 days is 55%, the base rate is 0.55. Round-trip costs (commission, bid-ask spread, slippage) total approximately 0.35%. The breakeven fill rate is roughly 50.35%. Since 55% > 50.35%, the base rate provides a margin of safety and supports trading this case. If the measured fill rate is 48%, the base rate does not support trading; either lower the gap-size threshold to find a higher-probability subset, or trade a different instrument.
Out-of-sample validation. Use the first 252 days to measure fill rates and lock in entry rules. Then paper-trade or backtest on the next 60-120 days of fresh data without reoptimizing parameters. Track: count of trades, win rate (percentage that exited at the limit), average win and loss size in points and percent, profit factor (gross profit / gross loss), and the fraction of gross P&L consumed by commission and slippage.
Realistic cost assumptions. The code includes 0.15% commission and 1-point slippage. Adjust these to match the trader's actual market and broker. If trading a $400 stock with a 0.5% gap (a $2 gap) and a 0.20% stop ($0.80), 1 point of slippage (~$1) may be material. If trading a $100 stock, 1 point may be negligible. Run sensitivity tests by varying commission and slippage parameters to confirm the strategy remains profitable under realistic worst-case execution.
Why a handful of trades proves nothing. A strategy with a 55% expected win rate will exhibit random variation. Over 20 trades, expect approximately 11 wins, but samples of 8 or 14 wins are statistically plausible. Only after 50+ trades does the observed win rate converge to the true rate. Evaluating a strategy on 3-4 trades is a form of small-sample bias and typically leads to overconfidence or premature abandonment.
Limitations
Regime dependence and temporal instability. Gap fill rates are not stationary. In strong bull markets, gaps up often extend rather than fill; in correction or crash environments, gaps down frequently accelerate downward. A base rate measured over 2023-2024 may not hold in 2025-2026. The code recalculates the base rate on every bar using a rolling 252-day window, which provides some adaptation, but the window itself lags regime changes. Practitioners must re-measure fill rates quarterly and suspend trading if the base rate drops below breakeven. A sudden regime shift (e.g., shift in overnight news flow, structural change in market maker behavior) can render the lookback obsolete within weeks.
Costs consume small edges. Gap fills typically deliver small profits: a 0.5% gap with a 55% fill rate and a 0.20% stop yields an expected profit of roughly 0.5% × 55% − 0.20% × 45% − 0.35% (costs) = 0.14% per trade. Over 40 trades per year, this totals 5.6% annual gross return before reinvestment and portfolio overhead. After broker fees, fund management costs, and slippage degradation in real execution, net returns may be 1-3% annually. The strategy is viable only for traders with low-cost execution and high trading volume.
Overfitting and sample-specific patterns. If a trader measures "QQQ gap-downs filled 62% of the time over 2023-2024" and builds rules around that cohort, there is significant overfitting risk. QQQ's high volatility and retail concentration may create gap-fill patterns unique to that ETF or that historical period. Backtesting on the same sample used to select thresholds inflates reported win rates. Walk-forward validation (roll forward 90 days, remeasure, trade, repeat) is mandatory to detect overfitting. A pattern that works on the training sample may perform substantially worse on truly out-of-sample data.
Execution risk and market microstructure. Large gaps often coincide with poor liquidity and wide bid-ask spreads at the open. A short-sale entry on a gap-up in a low-float stock may execute at a price 0.5-1.0% worse than the open, immediately eroding the expected edge. Similarly, limit orders to exit at the previous close may fail to fill during volatile intraday moves, forcing the trader to accept the time-stop exit at market price and forfeiting the target profit. Real-world execution slippage often exceeds backtested assumptions, particularly in the first few minutes of the session.
Data integrity and ex-dividend distortions. Gap-fill calculations depend on accurate high-low-close data. Gaps that result from ex-dividend adjustments, stock splits, or corporate actions (spin-offs, mergers) are not true overnight price gaps and may distort the base-rate measurement. Similarly, if historical data has been adjusted for splits but not properly aligned with corporate actions, the base rate is invalid. Data quality verification, especially around ex-dates and splits, is essential before relying on the calculation.
No mechanistic model. This strategy is purely empirical: it identifies that gaps have a certain fill rate and trades accordingly. It does not model why fills occur (e.g., algorithmic reversion, retail order clustering, market maker inventory management, news dissipation). If the causal mechanism changes, due to regulatory shifts, changes in market structure, or shifts in participant behavior, the fill rate may collapse without warning. The strategy has no leading indicator or mechanistic early warning. It is vulnerable to structural regime change that a causal model might anticipate.
Missing evidence. This paper presents no backtest results, win rates, or performance statistics. Before trading this strategy, a rigorous evaluation requires:
- Multi-year backtests across multiple liquid instruments with realistic costs and actual market microstructure (bid-ask, depth, slippage from order flow data or brokerage logs)
- Analysis of whether fill rates remain stable over rolling 12-month windows or deteriorate over time
- Stratified analysis: do fill rates vary by market condition (VIX level, direction of market, volume, time of day, day of week)?
- Walk-forward validation to confirm the strategy is not overfitted to the training sample
- Comparison to a buy-and-hold benchmark, to confirm the edge is real and not an artifact of survivorship bias or look-ahead bias in the data
None of this has been performed for this paper. The strategy is presented as a framework and starting point for rigorous testing, not as a proven or live-traded system.
Key Definitions
Base Rate: The unconditional frequency or probability of an outcome within a reference class. For example, if 55 out of 100 gaps-down over the past 252 days closed intraday within four hours, the base rate of gap-down fills is 55%.
Gap Fill: A price movement that closes or largely eliminates an overnight gap. If a stock closes at $100 and opens at $101.50 (a 1.5% gap up) and then trades down to $100.10 by 1:30 PM, the gap is nearly filled.
Breakeven Fill Rate: The minimum fill rate (as a percentage of trade attempts) required to recover transaction costs and achieve zero net profit. If round-trip costs equal 0.35%, a breakeven fill rate is approximately 50.35%.
Mean Reversion: The tendency for prices that have moved significantly away from a recent reference price (such as the prior close) to move back toward that reference over a short time horizon.
Bid-Ask Spread: The difference between the highest price a buyer will pay (bid) and the lowest price a seller will accept (ask) for a security at a given moment. Traders typically execute at these prices, incurring the spread as an implicit transaction cost.
Slippage: The difference between the expected execution price and the actual price at which an order fills, typically due to market impact and liquidity constraints. In fast-moving markets (such as at gaps), slippage can exceed the assumed amount.
Session Filter: A rule that restricts trading to certain hours, days, or market conditions. Example: "trade only the first four hours after market open" or "do not trade on days with major economic announcements."
Figures
References
-
Securities and Exchange Commission, "Regular Trading Hours for U.S. Equities", https://www.sec.gov/cgi-bin/viewer?action=view&cro_document_id=0001193125-18-366&cro_sequence_num=0 (2018) (primary)
-
Jegadeesh, N. & Titman, S. "Returns to Buying Winners and Selling Losers: Implications for Stock Market Efficiency." Journal of Finance, vol. 48, no. 1, pp. 65-91 (1993).
-
Tversky, A. & Kahneman, D. "Judgment Under Uncertainty: Heuristics and Biases." Science, vol. 185, no. 4157, pp. 1124-1131 (1974).
-
CME Group, "E-Mini S&P 500 Futures: Contract Specifications", https://www.cmegroup.com/markets/indices/equity/e-mini-sandp-500.html (Accessed 2025) (primary)
-
Investopedia, "Gap", https://www.investopedia.com/terms/g/gap.asp (Accessed 2025)
Key definitions
Gap: The percentage price change between the previous trading session's close and the current session's open, reflecting overnight news, macroeconomic releases, or order imbalance.
Gap fill: The intraday price movement that returns to or passes through the previous session's close level within a specified time window.
Base rate: The empirical frequency of an outcome (e.g., gap fills) measured across a historical sample period, used as the prior probability before applying specific entry conditions.
Fill rate: The percentage of gaps in a given direction that close within a specified intraday time window, calculated as the ratio of filled gaps to total gaps occurring over a lookback period.
Breakeven threshold: The minimum fill rate required for profitability after deducting round-trip transaction costs; approximately 50.35% given typical commission (0.15%), bid-ask spread (0.1%), and slippage (0.1%) expenses.
Position sizing: The calculation of the number of shares or contracts to trade, determined by dividing the fixed dollar risk amount (a percentage of account equity) by the distance in price from entry to stop-loss.
Time stop: An automated order that closes an open position at a specified time if neither the profit target nor stop-loss has been triggered.
Educational research on historical data only. Not investment advice, not a signal, and never a performance promise. Past results do not predict future performance. Every reference is link-verified before publication and every paper is re-audited weekly against the library's editorial standard.
Last reviewed by the PropLedger research pipeline: 2026-11-22. Educational research on historical data, not financial advice.
Keep reading
Donchian Channel Breakout: Entry Signals from Highest-High and Lowest-Low Volatility Bands
A complete, testable trading strategy: a Donchian channel breakout strategy: the classic trend-following rules, why they worked for decades, and the drawdown profile nobody advertises. Exact rules, full Pine Script code, and an honest reading of the evidence.
Auditable Trend Continuation: Operationalizing Price-Action Discretion
A complete, testable trading strategy: a discretionary trend-continuation playbook made auditable: how to write discretionary rules precisely enough that they can be backtested at all. Exact rules, full Pine Script code, and an honest reading of the evidence.
Liquidity Sweep Reversal at Session Extremes
A complete, testable trading strategy: a liquidity-sweep reversal strategy: sweeping a prior session high or low then reclaiming it, with precise rules and the failure cases that dominate. Exact rules, full Pine Script code, and an honest reading of the evidence.