Overview
Finds 3-candle fair value gaps (imbalances) and draws them as boxes that extend to the right until price fills them, with size filters and a box limit.
A fair value gap is a price area that one fast candle skipped, leaving no overlap between the candles on either side. Many traders watch these imbalances because price often comes back into them. This indicator marks every gap on closed candles and keeps it on the chart only while it is still open.
How it works
Three closed candles are checked: candle 1, candle 2 (the fast one) and candle 3.
- Bullish gap: the low of candle 3 is above the high of candle 1. The box covers
high[1]tolow[3]. - Bearish gap: the high of candle 3 is below the low of candle 1. The box covers
high[3]tolow[1]. - A gap is kept only if it passes both size filters: at least
Minimum gap pointsand at leastMinimum gap vs average rangex the average true range of the lastAverage range barscandles. - Open boxes start at candle 2 and are extended to the right on every new bar.
- A box is filled when a later candle (including the forming one) trades into it as set by
Fill mode: touch the edge, reach the middle, or trade through the whole gap. Filled boxes are deleted, or kept in grey and stopped at the fill candle. - When more than
Maximum boxesexist, the oldest box is removed first.
Inputs
| Input | Default | What it does |
|---|---|---|
| Minimum gap points | 0 | Smallest gap in points (0 = off) |
| Minimum gap vs average range | 0.10 | Smallest gap as a fraction of the average range (0 = off) |
| Average range bars | 14 | Bars for the average true range |
| History bars | 1500 | Bars to scan (0 = all) |
| Maximum boxes | 40 | Most boxes kept on the chart |
| Fill mode | Full | Touch, half (middle) or full fill |
| Show bullish / bearish | true / true | Which gaps to draw |
| Keep filled gaps | false | Keep filled boxes in grey |
| Fill boxes | true | Solid boxes or outline only |
| Extend bars | 5 | How far past the current bar open boxes reach |
| Bullish / bearish / filled colour | green / red / grey | Box colours |
| Alert on new gap | false | One alert when a new gap forms on a closed candle |
How to use it
- In MetaTrader open File > Open Data Folder.
- MT4: copy
FXN_FairValueGap.mq4intoMQL4/Indicators. MT5: copyFXN_FairValueGap.mq5intoMQL5/Indicators. - Right-click Indicators in the Navigator and choose Refresh (or restart the terminal). The file compiles on first use; you can also open it in MetaEditor and press Compile.
- Drag the indicator onto a chart and set the inputs.
A good start is the default 0.10 size filter on M15 to H4. Raise it to 0.25-0.5 to keep only clear imbalances. Use Half fill mode if you treat a return to the middle of the gap as "used". Combine with trend or structure: in an up-trend many traders only watch the bullish gaps below price.
Good to know
- Gaps are detected on closed candles only, so a box never appears and then disappears because the forming candle changed. A box can be closed by the forming candle, because a traded high or low cannot be undone.
- Four hidden buffers (bullish top/bottom, bearish top/bottom) are set on the third candle of each gap, so an EA can read new gaps with iCustom.
- On markets with weekend gaps (indices, crypto on some brokers) the session gap itself can show up as a fair value gap.
- It marks areas only; it does not predict whether price will react there.
Trading carries risk. Test on a demo account first; past results do not predict future results.
At a glance
- What it is
- A free Indicator for MetaTrader 5, written in MQL5.
- What it does
- Finds 3-candle fair value gaps (imbalances) and draws them as boxes that extend to the right until price fills them, with size filters and a box limit.
- Shared by
- Alex
- Licence
- MIT
- Version
- 1.0 (1 Dec 2026)
- Settings
- 15 inputs
- Lab check
- Compiled with MetaEditor build 6333 for MT5 on 1 Dec 2026: 0 errors, 0 warnings.
- Price
- Free to download
Settings read from the code
| Input | Type | Default | Note |
|---|---|---|---|
| InpMinGapPoints | int | 0 | Minimum gap size in points (0 = off) |
| InpMinGapAtr | double | 0.10 | Minimum gap size as a fraction of average range (0 = off) |
| InpAtrPeriod | int | 14 | Bars used for the average range |
| InpMaxBars | int | 1500 | History bars to scan (0 = all bars) |
| InpMaxZones | int | 40 | Maximum boxes kept on the chart (oldest removed first) |
| InpFillMode | ENUM_FVG_FILL | FVG_FILL_FULL | When a gap counts as filled |
| InpShowBullish | bool | true | Show bullish gaps |
| InpShowBearish | bool | true | Show bearish gaps |
| InpKeepFilled | bool | false | Keep filled gaps on the chart (greyed, stopped at the fill bar) |
| InpFillBoxes | bool | true | Fill the boxes (false = outline only) |
| InpExtendBars | int | 5 | How many bars past the current bar open boxes reach |
| InpBullColor | color | C'38,110,80' | Bullish gap colour |
| InpBearColor | color | C'140,45,55' | Bearish gap colour |
| InpFilledColor | color | clrDimGray | Filled gap colour (when kept) |
| InpAlertNew | bool | false | Alert once when a new gap forms on a closed bar |
How to use it
- Download the compiled file (or the source and compile it in MetaEditor).
- Put it in MetaTrader: File → Open Data Folder → MQL5 → Indicators, then refresh the Navigator.
- Test it on a demo account before any real money.
- Want changes? Open a copy in your Lab and ask for them in plain words.