Watch how to download trading robots for free
Find us on Telegram!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Indicators

Fair Value Gap Detector Indicator - indicator for MetaTrader 5

Olamide Daniel Adebayo
Olamide Daniel Adebayo
MQL5 Developer • Trading Tools • EAs • Products • Articles
Building, learning, and sharing one project at a time.
Views:
119
Rating:
(2)
Published:
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

Fair Value Gap Detector

The idea behind it

A Fair Value Gap forms when a strong, impulsive candle leaves a price range untouched by the candles immediately before and after it — the classic 3-candle imbalance: if the low of candle 3 is above the high of candle 1, no trading occurred in that gap, and price often revisits it later to "fill" the imbalance before continuing. This indicator scans every closed bar for that exact 3-candle relationship (in both directions), and the moment one is found, draws the gap zone as a rectangle spanning from the impulsive candle forward.

Each gap is tracked individually after that: while unmitigated, its box keeps stretching forward to the current bar in real time; the instant a later candle's range trades back into the zone, the box freezes exactly where mitigation happened and (by default) turns gray, so at a glance you can tell which gaps are still "live" untouched imbalances and which have already been revisited.

How to interpret it

  • Bullish gap (default green/white) — the low of the third candle is above the high of the first candle. Untouched space below current price that the market left behind on the way up; often watched as potential support on a pullback.
  • Bearish gap (default red) — the high of the third candle is below the low of the first candle. Untouched space above current price left behind on the way down; often watched as potential resistance on a bounce.
  • An extending (colored) box — the gap is still unmitigated; its right edge keeps moving forward live with InpExtendUntilMitigated enabled (default), or stops after a fixed InpExtendBars bars if disabled.
  • A frozen, gray box — the gap has been mitigated: a later candle's range traded back through the zone, and the box stopped exactly at that bar. Set InpHideMitigatedGaps to delete mitigated boxes instead of graying them out, for a cleaner chart.
  • Minimum size filterInpMinGapSizePoints discards gaps too small to be meaningful noise on the current symbol's tick size.

External variables (inputs)

Input Default Purpose
InpMinGapSizePoints 50 Minimum gap size, in points, for a detected imbalance to be drawn — filters out negligible gaps.
InpMaxGapsToShow 50 Maximum number of gaps kept on the chart at once; the single oldest tracked gap is dropped whenever a new one exceeds this cap.
InpExtendUntilMitigated true When true, an unmitigated gap's box keeps extending live to the current bar; when false, it stops after a fixed number of bars.
InpExtendBars 20 Fixed extension length (in bars), used only when InpExtendUntilMitigated is false.
InpHideMitigatedGaps false When true, a gap's box is deleted the moment it's mitigated instead of being grayed out and kept.
InpBullishColor / InpBearishColor Lime / Red Colors for unmitigated bullish and bearish gap boxes.
InpMitigatedColor Dim Gray Color a gap's box changes to once mitigated (when not hidden).
InpFillBox true Whether gap boxes are filled or drawn as outlines only.
InpBoxStyle / InpBoxWidth Solid / 1 Border style and width of every gap box.

Recommended use

Works on any symbol and any timeframe; imbalances are a pure price-action pattern with no symbol-specific assumptions, though they read most cleanly on timeframes with real intrabar structure (M1–H4) rather than very high timeframes where a single "candle" already represents an entire trading session. Detection and mitigation checks only run on fully closed bars by design, so a gap will not appear or disappear mid-candle as the current bar's high/low are still changing — expect a newly formed gap to show up right as the next bar opens, not tick-by-tick during formation.

On very long chart histories, thousands of small gaps can accumulate; InpMinGapSizePoints and InpMaxGapsToShow exist specifically to keep the chart readable and the object count bounded rather than letting every historical imbalance pile up indefinitely. This indicator only reads price data and never places, modifies, or closes any order, so it is safe to run on any account type.

All chart objects are created under a single internal name prefix and are fully removed via ObjectsDeleteAll() in OnDeinit() when the indicator is detached, so it leaves nothing behind on the chart.



Fig. 1. An unmitigated bullish gap and a mitigated bearish gap on XAUUSD M15. Rendered in black and white per the Code Base image guidelines (750×500 px).

Interactive On-Chart Risk Management and Execution Panel Interactive On-Chart Risk Management and Execution Panel

An interactive GUI panel for MetaTrader 5 designed for manual traders and quant developers. It automates dynamic position sizing based on exact account equity risk percentage, features one-click order execution (Buy/Sell), instant BreakEven, Close All functionality, and continuous real-time Trailing Stop management.

Chaos Theory Lyapunov Exponent EA Chaos Theory Lyapunov Exponent EA

Quantitative MT5 Expert Advisor that filters market noise using Chaos Theory and the Largest Lyapunov Exponent (LLE). Trades momentum EMA crossovers only during deterministic market regimes, with built-in ATR risk management.

Neural Loss-Pattern Auditor Neural Loss-Pattern Auditor

Neural Loss-Pattern Auditor trains a small feed-forward neural network, written from scratch in native MQL5, on closed-deal history to test whether behavioral and market-context features predict which trades are more likely to lose. It reports an accuracy uplift over a naive baseline, a probability-calibration table, a permutation feature-importance ranking, and a configurable A-F composite grade with recommendations. On first run it uses a built-in synthetic demo, so the output is visible immediately with no setup; switch one input to InpUseDemoData=false to analyze real account history instead. Pure MQL5: no external libraries, no Python, and no AI service of any kind.

MACD Signals MACD Signals

Indicator edition for new platform.