Inversion fair value gaps
All indicators

LibraryMarket structure

Indicator

Inversion fair value gaps

Fair value gaps that price has closed through, kept as zones of the opposite side: a bullish gap broken down turns into resistance, a bearish gap broken up into support.

Market structureOn the price3 inputsiFVG

How it is calculated

Gaps are found as in fvg (third candle against the first, at least min_size ATRs). A bullish gap is inverted on the first close below its bottom and becomes a bearish zone with the same top and bottom; a bearish gap on the first close above its top becomes a bullish zone. An inverted zone ends on a close back through its far side: a bullish one below its bottom, a bearish one above its top.

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

How to read it

The lines show the nearest bullish zone (the highest) and the nearest bearish one (the lowest). new is 1 on the bar that inverts a gap, broken on the bar that ends a zone. Gaps waiting to be inverted and inverted zones are each kept up to max_zones per side.

In a strategy

Sell the retest of a broken gap: when z = ctx.ind("ifvg", atr_length=14, min_size=0.25) has z.bear_new of 1, a short limit at z.bear_bottom with the stop above z.bear_top.

Inputs

InputTypeDefaultRange or choices
ATR lengthatr_lengthWhole number14min 1, max 500
Minimum size (ATR)min_sizeNumber0.25min 0, max 10
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