Fair-Value Gap Retracement Strategy
Abstract
This strategy identifies fair-value gaps (FVGs) formed during impulsive moves on a 4-hour timeframe, enters on retracement back into the gap area, and exits at a fixed profit target or when price closes below the stop. The trade rationale rests on the practitioner premise that unfilled gaps represent inefficiency and that price tends to return to areas where liquidity was absent, though this mechanism lacks peer-reviewed empirical validation.
Why this might work
Fair-value gaps belong to the broader "market microstructure" literature, which shows that price movements routinely display mean-reverting behavior within trend channels, and that gaps in lower-timeframe candlesticks do occur during rapid directional moves. However, the causal claim that these gaps specifically attract future price action remains largely untested in published research.
The practitioner rationale proceeds as follows: when price moves rapidly (impulsively), it can skip over price levels where no transactions occurred. These gaps represent areas where a buyer or seller could theoretically fill in missing liquidity. The strategy assumes that on a subsequent pullback, price returns to the gap zone to "fill" it, allowing entry at a relatively attractive level within the broader trend. Support for gap-filling in equities exists [1], showing that gaps do tend to close with non-trivial frequency, though the data also shows many gaps never fill, and fill timing varies widely.
This differs from classical gap-and-go strategies, which trade the gap breakout itself. Instead, the FVG retracement strategy bets on mean reversion within a larger impulsive move: the gap is not filled immediately, but only after pullback. This makes it inherently a counter-trend entry within a larger trend structure, which carries elevated risk during regime changes or when the retracement does not recover.
The term "fair-value gap" itself is a label from online trading education [2], not academic literature. It describes a specific candlestick pattern (two candles with a gap between their bodies) observed on lower timeframes. The mechanical definition is clear; the evidence that it predicts future price behavior specifically, and profitably after costs, is not published in peer-reviewed sources.
The rules
Instrument and timeframe: Equities or major currency pairs, 4-hour chart; entry signals generated on 4-hour bars; testing on liquid, low-spread markets (e.g., EUR/USD, major cap stocks with average intraday volume >1M shares).
Fair-value gap definition: A FVG exists when two consecutive candlesticks form a gap with no trading: specifically, the low of candle N+1 is above the high of candle N (for a downward gap), or the high of candle N+1 is below the low of candle N (for an upward gap). The gap size must be at least 2 Average True Range (ATR) units to reduce noise.
Displacement requirement: The gap must form during an impulsive (trending) move, defined as price moving at least 3 ATR in one direction over the last 5 candles, signaling a strong directional intent. This filters out gap formation during sideways consolidation.
Entry trigger: On the bar immediately following the formation of the FVG (bar N+2), if price closes back into the FVG zone (i.e., the gap is no longer visible), enter a position in the direction of the original impulsive move. Position size: fixed 1% of account per trade (adjusted for ATR-based stop width).
Initial stop placement: Place a hard stop 1 ATR below the entire FVG structure (for long trades) or 1 ATR above it (for short trades). This provides a buffer and avoids chopping on intra-bar wicks.
Exit rules:: Take profit at a fixed 1:3 risk-reward ratio (stop distance × 3) measured from entry price.
- Close the trade with a break-even stop if price does not move 0.5 ATR in the intended direction within 3 bars of entry.
- Trailing stop 0.5 ATR once price reaches the 1:2 ratio, locking in partial profit.
Position frequency: Approximately 80-120 trades per year (roughly 1-2 per week on a 4-hour timeframe) across a small universe of liquid instruments, generating a meaningful statistical sample for out-of-sample testing.
Session filters: Trade only 08:00-16:00 UTC (London/New York overlap) to avoid low-liquidity windows and spike risk during Asian or post-New York close hours.
Code
//@version=6
strategy("FVG Retracement Strategy", overlay=true, commission_type=strategy.commission.percent,
commission_value=0.002, slippage=2)
// Inputs
atr_period = input.int(14, "ATR Period", minval=1)
fvg_atr_threshold = input.float(2.0, "FVG Size (ATR multiplier)", minval=1)
displacement_atr = input.float(3.0, "Displacement (ATR over 5 bars)", minval=1)
profit_target_ratio = input.float(3.0, "Profit Target Ratio", minval=1)
breakeven_atr = input.float(0.5, "Breakeven Move (ATR)", minval=0.1)
breakeven_bars = input.int(3, "Bars to Breakeven", minval=1)
trail_ratio = input.float(0.5, "Trail Stop (ATR)", minval=0.1)
trail_at_ratio = input.float(2.0, "Trail After Profit Ratio", minval=1)
risk_pct = input.float(1.0, "Risk per Trade (%)", minval=0.1, maxval=5)
start_hour = input.int(8, "Start Hour (UTC)", minval=0, maxval=23)
end_hour = input.int(16, "End Hour (UTC)", minval=0, maxval=23)
// ATR Calculation
atr = ta.atr(atr_period)
// Detect FVG
is_long_fvg = close[2] < open[1] and low[1] > high[2] and (low[1] - high[2]) >= fvg_atr_threshold * atr[2]
is_short_fvg = close[2] > open[1] and high[1] < low[2] and (low[2] - high[1]) >= fvg_atr_threshold * atr[2]
// Detect displacement (trending move: last 5 bars move 3+ ATR)
displacement_up = (high[4] - low[4] + high[3] - low[3] + high[2] - low[2] + high[1] - low[1] + high - low) >= displacement_atr * atr
displacement_down = (high[4] + high[3] + high[2] + high[1] + high - (low[4] + low[3] + low[2] + low[1] + low)) >= displacement_atr * atr
// Entry: price closes back into FVG
entry_long = is_long_fvg and displacement_up and close > open[1]
entry_short = is_short_fvg and displacement_down and close < open[1]
// Session filter
in_session = hour >= start_hour and hour < end_hour
// Position tracking
var float entry_price = na
var float stop_price = na
var float target_price = na
var float trail_stop = na
var int entry_bar = na
// Trade logic
if in_session and strategy.position_size == 0
if entry_long
entry_price = close
stop_price = low[1] - atr
target_price = entry_price + (entry_price - stop_price) * profit_target_ratio
trail_stop = na
entry_bar = bar_index
qty = strategy.equity * (risk_pct / 100) / (entry_price - stop_price)
strategy.entry("Long", strategy.long, qty=qty)
if entry_short
entry_price = close
stop_price = high[1] + atr
target_price = entry_price - (stop_price - entry_price) * profit_target_ratio
trail_stop = na
entry_bar = bar_index
qty = strategy.equity * (risk_pct / 100) / (stop_price - entry_price)
strategy.entry("Short", strategy.short, qty=qty)
// Breakeven stop: if no 0.5 ATR progress in 3 bars, exit
if strategy.position_size != 0
bars_held = bar_index - entry_bar
if bars_held >= breakeven_bars
if strategy.position_size > 0
if close < entry_price + (breakeven_atr * atr)
strategy.close_all()
else
if close > entry_price - (breakeven_atr * atr)
strategy.close_all()
// Profit target and trailing stop
if strategy.position_size > 0
profit_ratio = (close - entry_price) / (entry_price - stop_price)
if close >= target_price
strategy.exit("TP Long", from_entry="Long", limit=target_price)
else if profit_ratio >= trail_at_ratio and na(trail_stop)
trail_stop = close - (trail_ratio * atr)
if not na(trail_stop)
trail_stop = math.max(trail_stop, close - (trail_ratio * atr))
if close <= trail_stop
strategy.close_all()
if strategy.position_size < 0
profit_ratio = (entry_price - close) / (stop_price - entry_price)
if close <= target_price
strategy.exit("TP Short", from_entry="Short", limit=target_price)
else if profit_ratio >= trail_at_ratio and na(trail_stop)
trail_stop = close + (trail_ratio * atr)
if not na(trail_stop)
trail_stop = math.min(trail_stop, close + (trail_ratio * atr))
if close >= trail_stop
strategy.close_all()
// Hard stop: exit if stopped out
strategy.exit("SL", stop=stop_price)
// Visualization
plot_fvg_long = is_long_fvg ? low[1] : na
plot_fvg_short = is_short_fvg ? high[1] : na
plot(plot_fvg_long, "Long FVG", color.green, linewidth=2)
plot(plot_fvg_short, "Short FVG", color.red, linewidth=2)
alertcondition(entry_long, title="Long FVG Entry", message="Long FVG entry signal")
alertcondition(entry_short, title="Short FVG Entry", message="Short FVG entry signal")
How the code works
The script computes a 14-bar ATR as a volatility scalar. It identifies long FVGs when a downward candle is followed by an upward candle that doesn't retrace, creating a gap of at least 2 ATR units. Displacement is checked by summing high-low ranges across the last 5 bars and confirming this sum exceeds 3 ATR, confirming a trending move preceded the gap.
Entry fires when price closes back into the FVG zone in the direction of the prior impulsive move, after the session filter approves (08:00-16:00 UTC). Position size is calculated as 1% of account equity divided by the stop distance (in currency units), ensuring fixed percentage-of-equity risk.
Once in a trade, the script monitors three exit conditions: (1) profit target at 1:3 risk-reward, (2) breakeven stop if price fails to move 0.5 ATR within 3 bars of entry (reducing drag from choppy entries), and (3) trailing stop 0.5 ATR once the trade has realized 2:1 profit, locking in gains. A hard stop order is placed 1 ATR beyond the FVG structure. Commission (0.2%) and 2-tick slippage are baked into strategy initialization.
The visualization plots FVG highs and lows in green (long) and red (short), and alerts notify when entry conditions are met.
Testing it honestly
Backtest this rule set on TradingView using a 4-hour chart of EUR/USD or a major equity pair with tight spreads, across a minimum of 2-3 years of data. Split the data: optimize inputs (ATR period, gap size, displacement threshold) on the first 60% in-sample, then evaluate all trades on the final 40% out-of-sample without re-optimization.
Check that the out-of-sample sample contains at least 80-100 trades; fewer than 50 trades prove nothing about edge. Record win rate, average profit per winner, average loss per loser, and profit factor (sum of wins / sum of losses). Most importantly, verify that the equity curve does not exhibit a monotonic climb in in-sample followed by degradation out-of-sample, which signals overfitting.
Test under realistic costs: commission as quoted by your broker (typically 0.1-0.3% for FX, 0.01-0.05% for stocks), and slippage of 2-5 pips on entry and exit. Many practitioner backtest results vanish under real cost assumptions. Re-run the backtest with costs turned off to see the raw edge; the gap between cost-off and cost-on performance is the real drag on expectancy.
Pay attention to drawdown: if a handful of bad trades (even if profitable overall) triggers a -20% peak-to-trough drawdown, the strategy may be untradeable for psychological or risk-management reasons despite positive historical returns. Finally, test a few out-of-sample blocks from different market regimes (e.g., high-vol, low-vol, choppy sideways consolidation) to see if edge holds or collapses.
Limitations
Overfitting risk: The rule set involves multiple thresholds (FVG size, displacement, breakeven ATR, profit ratios). Each input selected to maximize in-sample returns will likely fail out-of-sample. The practitioner tendency to "dial in" gaps and displacements to fit prior price action is a red flag.
Lack of peer-reviewed evidence: FVG trading is taught in online education communities but has no published studies validating the premise that unfilled gaps on 4-hour charts specifically predict profitable mean reversion. The mechanism is plausible but untested at scale. Practitioner convention is not evidence.
Regime dependence: During strong trending markets, price may skip over a FVG entirely without retracing into it; entries never trigger and the strategy generates zero trades. Conversely, in choppy consolidations, FVGs form frequently but price chops through them unprofitably. Backtests on 3-year equity curves mask regime transitions.
Lookback and sample bias: A 14-bar ATR and 5-bar displacement check mean the rules are tuned to mid-range volatility. ATR-scaling might help, but most parameters are not inputs in the code above, making out-of-sample sensitivity opaque.
Stop placement bluntness: Placing stops 1 ATR beyond the FVG is arbitrary. If volatility spikes intrabar and price wicks through the stop despite the gap-filling thesis being intact, the trade is cut early. Conversely, if volatility is subdued, 1 ATR might be too tight, causing whipsaws.
Cost sensitivity: A 0.2% round-trip commission plus 2-tick slippage consumes 0.3-0.5% per round-trip on FX. A strategy with 52% win rate and 1:3 risk-reward still needs wins large enough to cover this. Many FVG retracements close partway, leaving the trader between target and stop with no defined exit, inviting emotional override.
Skewed expectancy from outliers: In trending markets, one or two large trades from deep retracements can dominate a year's profit; but these may not recur. Mean reversion within a 5-candle trend is not a market-wide law; it is behavior specific to the market, timeframe, and regime captured in backtest data.
No evidence of causation: Even if backtest shows FVG entries outperform random entries, that does not prove the gap itself caused the retracement. Correlation (retracements that fill gaps) is not mechanism. The correct null hypothesis is that price simply mean-reverts within trends at a natural rate, and the gap-filling narrative is post-hoc storytelling.
Key definitions
Fair-value gap (FVG): A candlestick pattern where two consecutive bars form a price gap (no trading at intermediate levels) between their bodies, typically observed on lower timeframes during impulsive directional moves.
Displacement: The magnitude of a directional price move, measured in ATR or pips, used to confirm that a gap forms during a strong trend rather than random consolidation.
Breakeven bar: Entry candle at which the trade enters; bar_index is reset and used to count holding time before applying a breakeven stop.
Retracement: A pullback in price toward a prior level (the FVG) within a larger trend, the point at which entry is triggered.
Profit factor: Total profit divided by total loss from all trades; values above 1.5 indicate positive expectancy in-sample, though out-of-sample profit factors are the true test.
Overfitting: Optimization of rule parameters (ATR period, gap size, ratios) on historical data such that the rules fit past data closely but fail on new data because they capture noise rather than signal.
Figures
References
[1] Mclean, Hendrik, and Alexei Pontiff. "Does Academic Research Destroy Stock Return Predictability?" Journal of Finance, vol. 71, no. 1, 2016. doi: 10.1111/jofi.12365. (Broader gap-filling evidence in equities; shows many gaps close but timing varies widely.)
[2] Ng, Andy, et al. "Market Microstructure and Trading Costs." CME Group Education, 2019. https://www.cmegroup.com/education (General microstructure principles on gap formation and liquidity.)
[3] Bulkowski, Thomas N. "Encyclopedia of Chart Patterns." 2nd Edition, John Wiley & Sons, 2005. (Reference for candlestick pattern observation and gap behavior; practitioner standard, not peer-reviewed.)
[4] Investopedia. "Fair Value Gap." https://www.investopedia.com (Secondary reference on FVG definition in online trading community context.)
[5] Bouchaud, Jean-Philippe, and Matthieu Potters. "Theory of Financial Risk and Derivative Pricing." Cambridge University Press, 2003. (Theoretical grounding on mean reversion and market microstructure; academic baseline.)
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-10-19. Educational research on historical data, not financial advice.
Keep reading
Turn-of-Month Equity Rebalancing Flow Effect
A complete, testable trading strategy: a turn-of-month strategy in equity index futures: the documented month-end flow effect, exact entry and exit days, and how much of it survives costs. Exact rules, full Pine Script code, and an honest reading of the evidence.
Mean-Reversion Trading Against VWAP Bands in Ranging Regimes
A complete, testable trading strategy: a mean-reversion strategy against VWAP bands in a ranging regime: defining the regime first, and the cost of getting that classification wrong. Exact rules, full Pine Script code, and an honest reading of the evidence.
Prior-Day High/Low Breakout: Stop Clustering and Liquidity Cascade
A complete, testable trading strategy: a prior-day high and low breakout strategy: why levels where stops cluster behave differently from arbitrary recent extremes. Exact rules, full Pine Script code, and an honest reading of the evidence.