Discussing the article: "Building a Modular Fair Value Gap (FVG) Detection Engine in MQL5"

 

Check out the new article: Building a Modular Fair Value Gap (FVG) Detection Engine in MQL5.

This article introduces a modular Fair Value Gap (FVG) detection engine for MQL5 packaged as a reusable include class, it evaluates imbalance zones on closed bars, applies a Simple True Range average filter to eliminate low-volatility noise, and supports wick-touch and close-through mitigation. A companion diagnostic indicator plots active gaps, and an Expert Advisor template demonstrates automated pullback entries with new-bar execution controls.

When developing automated trading systems in MQL5, developers frequently use standard technical indicators as trend filters or dynamic support levels. While indicators like moving averages or oscillators provide smooth visual references, they inherently suffer from mathematical lag because they compute values by smoothing historical prices. In high-volatility market regimes, lagging indicators can generate entry signals well after an expansion move has already initiated.

To complement traditional indicators, price action traders analyze structural market imbalances directly from raw candlestick patterns. One effective method is scanning for Fair Value Gaps (FVG)—three-candle structural voids created when aggressive buying or selling activity leaves an inefficiently filled price range.

MQL5 does not include built-in functions to dynamically identify, filter, and manage FVG zones across multiple charts and timeframes. Embedding this calculation logic directly inside an Expert Advisor's event loop creates rigid, single-purpose code. This article presents a modular, object-oriented Fair Value Gap detection engine in MQL5. We formalize the pattern mathematics, apply a Simple True Range (TR) average filter to eliminate low-volatility noise, build a diagnostic indicator for visual validation, and provide an Expert Advisor integration template.

Author: Amanda Vitoria De Paula Pereira