Skip to content

Free MT5 indicator

Fair Value Gaps

Detects three-candle fair value gaps above a minimum ATR size and extends each rectangle until price fills the gap.

Smart moneyv1.0MetaTrader 5 (MQL5) Compiles with 0 errors Non-repainting signals Alerts

What it does

FXP Fair Value Gaps finds three-candle imbalances: places where price moved so quickly that the first and third candles of a sequence do not overlap. Each gap is drawn as a rectangle that extends to the right until price comes back and fills it.

A minimum size measured in ATR keeps tiny, meaningless gaps off the chart, and caps on the number of open and filled gaps keep it tidy.

How it works

For every closed candle c, the indicator looks at candles c-2, c-1 and c:

  • Bullish gap: the low of candle c is above the high of candle c-2. The gap runs from the high of c-2 (bottom) to the low of c (top).
  • Bearish gap: the high of candle c is below the low of candle c-2. The gap runs from the high of c (bottom) to the low of c-2 (top).
  • The gap height must be at least the chosen multiple of the ATR (Wilder smoothing, 14 bars by default) measured on candle c-1.

On each later closed candle, every open gap is tested against the fill rule. Full fill (default): a bullish gap is filled when a low reaches its bottom, a bearish gap when a high reaches its top. Midpoint fill uses the middle of the gap, and touch uses the near edge. Filled gaps are deleted or greyed and frozen at the filling bar.

Calculations run on closed candles only, and only new bars are processed on each tick.

How to use it

Copy the .ex5 file into MQL5/Indicators and attach it to a chart.

Gaps show where one side was in control and the other barely traded. Some traders expect price to revisit these areas and watch for reactions near the midpoint, especially when the gap sits in the direction of the higher-timeframe trend. A gap that price ignores and leaves behind can also confirm that a move is strong.

Typical use: mark H1 or H4 gaps, then drop to M5 or M15 to see how price behaves when it returns. Raising the minimum size to 0.5 to 1.0 ATR keeps only the more significant gaps. Read about volatility to understand why ATR-based filters adapt to quiet and busy markets.

Settings

InputDefaultWhat it changes
Minimum gap size (x ATR)0.3Filters out small gaps.
ATR period14Volatility reference.
Show bullish gaps / Show bearish gapstrue / trueToggle each side.
History bars to analyse1500Look-back for drawing.
Gap counts as filled whenWhole gapFull, midpoint or touch rule.
Filled gapsDeleteDelete or keep as grey.
Max open gaps kept (per side)20Oldest open gaps are removed beyond this.
Max filled gaps kept20Only used when filled gaps are kept.
Extend open gaps right by N bars5Projection beyond the last candle.
Colorsgreen / red / greyBullish, bearish and filled colors.
Alert on new gapfalseOne alert per bar.

Limitations

  • Gaps are common on low timeframes and many are filled within a few bars without any notable reaction.
  • Weekend and session-open gaps create imbalances that reflect closed markets rather than aggressive orders.
  • On instruments with very wide spreads, the bid-based chart may show gaps that were not tradable.
  • A gap is an observation about past price, not a signal on its own. Use a stop-loss and size positions carefully. Trading involves substantial risk of loss.

Key inputs

Key inputs of Fair Value Gaps
InputDefaultDescription
Minimum gap size (x ATR)0.3Ignores gaps smaller than this fraction of the ATR.
ATR period14Bars used for the Average True Range.
Gap counts as filled whenPrice trades through the whole gapFull fill, midpoint fill, or first touch.
Filled gapsDelete rectangleDelete filled gaps or keep them greyed out.
Max open gaps kept (per side)20Caps the number of open gaps on the chart.
Alert on new gap (once per bar)falseAlerts when the last closed candle completes a gap.

Educational tools, not advice. Indicators and Expert Advisors describe price; they do not predict it, and past behaviour does not guarantee future results. Test everything on a demo account first and never risk money you cannot afford to lose. See our disclaimer.

Keep exploring

Related mt5 indicators