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
| Input | Default | What it changes |
|---|---|---|
| Minimum gap size (x ATR) | 0.3 | Filters out small gaps. |
| ATR period | 14 | Volatility reference. |
| Show bullish gaps / Show bearish gaps | true / true | Toggle each side. |
| History bars to analyse | 1500 | Look-back for drawing. |
| Gap counts as filled when | Whole gap | Full, midpoint or touch rule. |
| Filled gaps | Delete | Delete or keep as grey. |
| Max open gaps kept (per side) | 20 | Oldest open gaps are removed beyond this. |
| Max filled gaps kept | 20 | Only used when filled gaps are kept. |
| Extend open gaps right by N bars | 5 | Projection beyond the last candle. |
| Colors | green / red / grey | Bullish, bearish and filled colors. |
| Alert on new gap | false | One 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.

