New free code from MQL5: indicators, EAs, and scripts for traders.
A fair value gap on Gold (XAUUSD) or any symbol is drawn only when the third candle closes: the low of candle three above the high of candle one for a bullish gap, the high of candle three below the low of candle one for a bearish gap. Gaps smaller than a fraction of ATR are skipped, so the chart keeps the imbalances that matter.
Each gap is followed after it forms. When price comes back, the box shrinks to the part that is still unfilled, so you see what is left of the imbalance, not the original rectangle. A gap is mitigated by touch, by the 50 percent line or by a full fill, as you choose, and then it is dimmed or removed.
It reads closed bars only, so what you see does not repaint. A gap is a zone where price often reacts, not a signal on its own. Combine it with structure and test it on your symbols before you trade it.
Watch in-depth trading tutorials and EA reviews on the RobotFX YouTube channel. Subscribe for free tips.
Settings
- Minimum gap size: fraction of ATR. 0.20 skips gaps smaller than 20 percent of ATR. 0 shows every gap.
- ATR period: period of the ATR used by the size filter. Default 14.
- Mitigation rule: Touch (price enters the gap), Midline (price reaches 50 percent) or Full fill (price crosses the far edge).
- Shrink the box: on, the box keeps only the part still unfilled. Off, it keeps its original size until mitigated.
- Bars to scan: history used on load. Default 1000.
- Show bullish / bearish, keep mitigated gaps, 50 percent line, maximum open gaps per side, maximum mitigated gaps and the four colours.
- Alerts: new gap and first touch of an open gap, by popup, push and sound. Only the bar that has just closed can alert.
- Object prefix: change it to run two copies with different settings on one chart.
What it needs
Any symbol, any timeframe, any broker. It only draws rectangles and lines on the chart, it never trades.
Make it yours
Run it on XAUUSD, EURUSD, GBPUSD, US30 or NAS100 and compare M5, M15 and H1: higher timeframes leave fewer gaps that hold longer. A gap left by the move that breaks structure is the classic Smart Money Concepts entry zone, so it pairs well with a BOS and CHoCH tool and with order blocks. The detection lives in XP_FindGap and the fill logic in XP_UpdateGaps, both easy to lift into your own EA as a filter or an entry trigger.
About this code
Open source. Use it as it is, adapt it, build your own version on top of it.
New versions and new tools are announced first on my MQL5 channel: https://www.mql5.com/en/channels/xander
Questions, suggestions and your own backtests are welcome in the Xander Lab group: https://www.mql5.com/en/messages/02eec85e4364dd01
More tools on my profile: https://www.mql5.com/en/users/09151993a
Provided as is, use at your own risk.
Related
- Order Blocks Zones SMC
- Smart Money Concepts BOS CHoCH
- Supply Demand Zones
Changelog
- v1.0 - 2026-11-02 - Initial release
Level up your trading with professional RobotFX expert advisors and indicators. Visit robotfx.org for proven MT4/MT5 tools.
79400