# Fair value gaps

`fair_value_gaps`

Three-candle imbalances, shown until price fills them.

## Inputs

| Name | Type | Default | Range |
| --- | --- | --- | --- |
| min_size | float | 0 |  |
| auto_threshold | bool | true |  |
| threshold_bars | int | 100 | 1 to 5000 |
| threshold_mult | float | 2 | 0.1 to 10 |
| extend | int | 0 | 0 to 5000 |
| mitigation | choice | filled |  |

## Outputs

| Name | Kind |
| --- | --- |
| bull_1 | zone |
| bull_2 | zone |
| bull_3 | zone |
| bull_4 | zone |
| bull_5 | zone |
| bear_1 | zone |
| bear_2 | zone |
| bear_3 | zone |
| bear_4 | zone |
| bear_5 | zone |
| bull_new | event |
| bear_new | event |
| bull_mitigated | event |
| bear_mitigated | event |

Warm-up: 0 bars (0 at the defaults).

Repaints: No.

## Formula

A bullish gap forms on a bar whose low is above the high two bars earlier, when the bar between them closes above that high. The gap runs from that earlier high up to the bar's low. A bearish gap mirrors it.

A gap is kept only when its height is at least min_size. With auto_threshold on, it is also kept only when the middle candle's body is larger than threshold_mult times the average body of the threshold_bars candles before it.

A gap shows from the bar it forms on. With mitigation filled, a bullish gap is mitigated when price trades below its bottom; with touched, when price trades into it. Bearish gaps mirror it. bull_mitigated and bear_mitigated mark the bar, and the gap is removed. With extend above zero, a gap shows on the bar it forms and the extend bars after it, then is removed.

Slot 1 is the newest live gap of its side; Forge keeps the five newest per side. A missing bar starts the scan again.

The gaps are found on the bars the indicator runs on, which can be another timeframe than the chart's.
