Fair value gaps
All indicators

LibraryMarket structure

Indicator

Fair value gaps

Three bar price gaps: ranges price jumped over so fast that the first and the third candle do not overlap, which often act as support or resistance when price comes back.

Market structureOn the price4 inputsFVG

How it is calculated

Bullish when the third candle's low is above the first candle's high: the gap runs from that high to that low. Bearish when the third high is below the first low. It counts when at least min_size times the ATR (Wilder, atr_length) at the third candle high. From the next bar a bullish gap is filled when a low reaches its bottom, or its middle with Filled at 50 %; bearish gaps mirror this.

Reference: ICT market structure, from public descriptions (#546)

How to read it

The lines show the nearest open bullish gap (the highest) and the nearest bearish one (the lowest); None when there is none. The new and filled flags are 1 on the bar of the event. A gap shows on its third candle, never earlier, and at most max_zones per side are kept.

In a strategy

Buy the retest: with g = ctx.ind("fvg", atr_length=14, min_size=0.25, fill="half") a long limit at g.bull_top with the stop below g.bull_bottom, cancelled when g.bull_filled is 1.

Inputs

InputTypeDefaultRange or choices
ATR lengthatr_lengthWhole number14min 1, max 500
Minimum size (ATR)min_sizeNumber0.25min 0, max 10
Filled atfillChoice"full"Full pass, 50 % (consequent encroachment)
Zones kept per sidemax_zonesWhole number20min 1, max 500

What it draws

LineDrawn as
Bullish topSteps
Bullish bottomSteps
Bearish topSteps
Bearish bottomSteps

Used in

No strategy template reads it yet.

OrionQuant