◆ New — Strategy Validator, Code Fixer & Prop Compliance Checker are live. Try one free →
Home / Strategies / Fair Value Gap (FVG) Strategy
Concept breakdown

Fair Value Gap (FVG) Strategy

A Fair Value Gap (FVG) is a three-candle price "imbalance" where the wicks of the first and third candles fail to overlap, leaving an untouched gap in the middle. Popularised in the smart-money / ICT community, it's an educational concept traders use to mark zones of one-sided order flow that price may later revisit. This page explains what an FVG is, how traders define entries, exits and risk around it, and gives a valid Pine v6 detection/marker script. It is educational only: an FVG is a chart-reading construct, not a prediction, and nothing here implies any outcome — trading involves the risk of loss.

How it works

A Fair Value Gap (also called an imbalance or inefficiency) describes a region on the chart that price moved through so quickly that, over three consecutive candles, buying and selling did not "trade fairly" against each other. It is defined geometrically on any single timeframe using three adjacent candles — call them candle 1 (oldest), candle 2 (the large move), and candle 3 (newest).

For a BULLISH FVG: the LOW of candle 3 is higher than the HIGH of candle 1. The empty band between candle 1's high and candle 3's low is the gap — a price range that the wicks never overlapped. For a BEARISH FVG: the HIGH of candle 3 is lower than the LOW of candle 1, leaving an unfilled band between candle 3's high and candle 1's low. The middle candle (candle 2) is typically a wide-range "expansion" candle in the direction of the gap, which is why the surrounding wicks fail to meet.

The idea taught in the smart-money / price-action community is that such gaps represent zones of imbalanced order flow, and that markets often (though not always) trade back into these unfilled areas later — a behaviour traders loosely call "rebalancing" or "filling the gap." Important: this is a descriptive heuristic, not a rule the market obeys. Many gaps are never filled; many are filled and price keeps going; the concept is not predictive.

Traders distinguish a few attributes: (1) the gap's boundaries (the two prices that define the band); (2) its midpoint or "consequent encroachment" (the 50% level), which some treat as a reference point; (3) whether the gap remains "unmitigated" (untouched) or has been partially/fully traded back into; and (4) the higher-timeframe context, since an FVG inside a clear trend or near a prior structural level is treated differently from one in choppy, directionless price. The concept is timeframe-agnostic: the same three-candle definition applies on a 1-minute or a weekly chart, and traders often look for a lower-timeframe FVG that lines up with a higher-timeframe zone of interest.

Because the entry/confirmation step is largely discretionary (see entry rules below), the FVG concept does not reduce cleanly to a single mechanical trading system. It reduces well to a DETECTION/MARKER, which is what the Pine script below provides — it locates and draws gaps so you can study them, rather than placing trades.

Entry rules

Exit rules

Risk notes

Pine v6 example

//@version=6
// Fair Value Gap (FVG) — ILLUSTRATIVE DETECTION / MARKER, not a trading system.
// The FVG concept does not reduce to a clean mechanical strategy (entry/confirmation
// is discretionary), so this script only DETECTS and DRAWS gaps for study.
// Educational only. Markers describe past structure; they are not predictive and
// nothing here implies any outcome. Trading involves the risk of loss.
indicator("FVG Detector (illustrative)", overlay = true, max_boxes_count = 500, max_lines_count = 500)

showBull   = input.bool(true,  "Show bullish FVGs")
showBear   = input.bool(true,  "Show bearish FVGs")
minGapPts  = input.float(0.0,  "Min gap size (price units, 0 = any)", minval = 0.0)
showMid    = input.bool(false, "Show 50% midpoint line")

// Three-candle pattern, confirmed on the close of the most recent bar (no future data):
//   candle 1 = [2] (oldest), candle 2 = [1] (expansion), candle 3 = [0] (current).
// Bullish gap: current low is above the high two bars ago.
// Bearish gap: current high is below the low two bars ago.
bullGap = low > high[2]
bearGap = high < low[2]

bullSize = low - high[2]
bearSize = low[2] - high

bigEnough(sz) => minGapPts == 0.0 or sz >= minGapPts

if barstate.isconfirmed
    if showBull and bullGap and bigEnough(bullSize)
        top    = low
        bottom = high[2]
        box.new(bar_index - 2, top, bar_index, bottom, border_color = color.new(color.teal, 0), bgcolor = color.new(color.teal, 85))
        if showMid
            mid = math.avg(top, bottom)
            line.new(bar_index - 2, mid, bar_index, mid, color = color.new(color.teal, 0), style = line.style_dotted)
    if showBear and bearGap and bigEnough(bearSize)
        top    = low[2]
        bottom = high
        box.new(bar_index - 2, top, bar_index, bottom, border_color = color.new(color.red, 0), bgcolor = color.new(color.red, 85))
        if showMid
            mid = math.avg(top, bottom)
            line.new(bar_index - 2, mid, bar_index, mid, color = color.new(color.red, 0), style = line.style_dotted)

// Optional non-repainting markers below/above the bar that created the gap.
plotshape(barstate.isconfirmed and showBull and bullGap and bigEnough(bullSize), title = "Bull FVG", style = shape.triangleup,   location = location.belowbar, size = size.tiny, color = color.teal)
plotshape(barstate.isconfirmed and showBear and bearGap and bigEnough(bearSize), title = "Bear FVG", style = shape.triangledown, location = location.abovebar, size = size.tiny, color = color.red)

Pitfalls

FAQ

What exactly counts as a Fair Value Gap?

It's a three-candle pattern. A bullish FVG exists when the low of the third candle is above the high of the first candle, leaving an untouched price band in the middle; a bearish FVG is the mirror image (third candle's high below the first candle's low). The middle candle is usually a wide expansion move. That gap band is the FVG. Different traders use wicks vs bodies, so define yours and stay consistent.

Does price always come back to fill a Fair Value Gap?

No. The notion that markets 'rebalance' imbalances is a tendency some traders observe, not a rule. Plenty of gaps are never filled, and plenty are filled while price keeps running. An FVG is a context marker, not a prediction or a guarantee, and using it carries the normal risk of loss.

Is the FVG a complete mechanical trading strategy?

Not really, which is why we present it as a concept and provide a detection/marker script rather than an auto-trading system. Locating a gap is mechanical, but the entry, confirmation and exit steps are largely discretionary (trend context, overlapping levels, the reaction on arrival). If you do encode a fixed rule, validate it for look-ahead bias and repainting first, and treat any backtest as illustrative only.

Does the detection script repaint?

It's written to confirm gaps on bar close using barstate.isconfirmed, so a marker for a completed three-candle pattern shouldn't change after the bar closes. That said, always run any FVG logic through a validator that explicitly checks for look-ahead bias and repainting before you trust its output — small changes to the conditions can reintroduce hindsight.

Educational & software only — not financial advice, not a recommendation to trade. Backtests are illustrative; past performance does not predict future results. Trading involves substantial risk of loss.

Catch the bug that compiles.Run auditGet Pro