MetaTrader MT5 Indicator 100% Free MQL Source Code

ICT Fair Value Gap (FVG) MT5 Indicator

RaptozGroupBy RaptozGroup
4.9 (120 reviews)
15,000+ Downloads
Fair Value Gap MT5 Indicator Example

ICT Fair Value Gap indicator on MT5 plotting bullish and bearish imbalance zones.

The ICT Fair Value Gap (FVG) MT5 Indicator is an advanced MQL5 technical tool designed for MetaTrader 5. It automatically scans the market for 3-candle imbalances, plots Consequent Encroachment levels, and sends push alerts upon void mitigation.

ICT Fair Value Gap (FVG) MT5 Indicator Overview

High-Speed Fair Value Gap Detection on MetaTrader 5

The Fair Value Gap (FVG) MT5 Indicator utilizes the native 64-bit multi-threaded architecture of MetaTrader 5 to scan multi-pair, multi-timeframe price series for liquidity voids. In institutional Smart Money analysis, an FVG represents a 3-candlestick market imbalance where aggressive volume displaced price rapidly, leaving one side of the auction book unfilled.

Because institutional algorithms actively rebalance inefficient order flow, price frequently retraces into these open voids. The MT5 indicator automatically plots Bullish (BISI) and Bearish (SIBI) imbalance boxes, projects 50% Consequent Encroachment (C.E.) reaction lines, and delivers instantaneous mobile push notifications when price penetrates unmitigated gaps.

BISI vs SIBI Imbalance Classifications

FVG patterns are divided into two primary structural forms depending on market direction and liquidity delivery:

Buyside Imbalance Sellside Inefficiency (BISI)

Forms during an explosive upward candle where buying volume dominates. The void between Candle 1 High and Candle 3 Low acts as fresh institutional demand support on pullbacks.

Sellside Imbalance Buyside Inefficiency (SIBI)

Forms during an aggressive downward candle where selling volume dominates. The void between Candle 1 Low and Candle 3 High acts as fresh institutional supply resistance on retracements.

Advanced Inversion FVGs (IFVG) & Balanced Price Ranges

Inversion Fair Value Gap (IFVG)

When an FVG is cleanly broken through by a closing candle, the former support level flips into a high-conviction resistance barrier (or vice versa).

Balanced Price Range (BPR)

Created when an upward BISI is immediately engulfed by a downward SIBI, highlighting an institutional fair value equilibrium pivot.

Consequent Encroachment (50% C.E.) & Invalidation Rules

In Smart Money trading, the 50% midpoint of an FVG box is termed Consequent Encroachment (C.E.). If price respects the C.E. level with long rejection wicks, the underlying institutional trend remains exceptionally strong. If price completely closes beyond the opposite boundary of the FVG, the imbalance is deemed invalidated and flips into an Inversion FVG (IFVG).

MQL5 Native High-Performance Architecture

  • 64-Bit Multi-Threading: Renders hundreds of historical imbalance boxes across all 21 MT5 timeframes without CPU bottlenecks.
  • Tick-Level Mitigation Verification: Evaluates tick stream data in real time to immediately remove or gray-out mitigated boxes.
  • Direct Push Alert System: Sends instant push notifications with symbol, timeframe, and gap coordinates to the MT5 mobile app.

Pro Trader Guidelines for Trading FVGs on MT5

  • Filter for Higher Timeframe Confluence: Prioritize 15-minute or 1-hour FVGs that form inside Daily or 4-Hour Order Blocks.
  • Monitor Session Openings: Look for displacement FVGs formed immediately after London Open (08:00 GMT) or New York Open (13:00 GMT).
  • Utilize Consequent Encroachment for Entry: Entering at the 50% C.E. level allows for tighter stop losses and improved 1:4+ risk-to-reward ratios.

Supported MT5 Timeframes & Execution Modes

TimeframeTrading ModeRecommended Strategy
M1 / M2 / M5Precision ScalpingExecute tight-stop entries inside higher-timeframe FVG zones.
M15 / M30Intraday TradingCatch London and New York session displacement imbalances.
H1 / H4Swing TradingIdentify major daily price voids for multi-day position expansion.
D1 / W1Macro SwingMacro institutional fair value delivery targets.

Key Features & Capabilities

Ultra-fast MQL5 calculation engine with zero chart lag
Auto-detects BISI and SIBI price imbalance gaps
Plots 50% Consequent Encroachment (C.E.) reaction lines
Mobile push notifications to iOS and Android MT5 apps
Works across Forex, Gold, Oil, Indices, and Crypto

Input Parameters & Settings Guide

Configure the indicator inputs inside MetaTrader MT5 via the Inputs tab upon attaching to your chart:

ParameterDefault ValueDescriptionRecommended
InpBullishFVGColorclrMediumSeaGreenColor for bullish imbalance boxesSeaGreen / Emerald
InpBearishFVGColorclrIndianRedColor for bearish imbalance boxesIndianRed / Crimson
InpMinGapPoints10Minimum gap filter size (points)10-25 points
InpPushAlertstrueSend alerts to MT5 mobile appTrue
InpShowMidpointCEtrueDisplay 50% Consequent Encroachment lineTrue

Trading Strategy & Entry Rules

1

Step 1: Multi-Timeframe Bias

Establish directional bias on H4/Daily using market structure breaks (BOS).

2

Step 2: Identify Inefficiency Voids

Locate prominent unmitigated Fair Value Gaps left behind by momentum displacement.

3

Step 3: Wait for 50% Equilibrium Fill

Watch for price to pull back cleanly into the 50% Consequent Encroachment (C.E.) zone.

4

Step 4: Lower Timeframe Execution

On M5, trigger entry on confirmed rejection patterns or Change of Character (CHoCH) with defined stop-loss limits.

MQL5 Source Code

//+------------------------------------------------------------------+
//|                                  FairValueGap_FVG_MT5.mq5        |
//|                    Copyright 2026, TraderSentiments Quant Team   |
//|                                    https://tradersentiments.com  |
//+------------------------------------------------------------------+
#property copyright "Copyright 2026, TraderSentiments"
#property link      "https://tradersentiments.com/indicators/mt5/smart-money/fair-value-gap-indicator"
#property version   "2.10"
#property indicator_chart_window

input color    InpBullishFVGColor  = clrMediumSeaGreen; // Bullish Imbalance Color
input color    InpBearishFVGColor  = clrIndianRed;      // Bearish Imbalance Color
input int      InpMinGapPoints     = 10;                // Minimum Gap Size (Points)
input bool     InpPushAlerts       = true;              // Mobile Push Notifications

int OnInit() {
   IndicatorSetString(INDICATOR_SHORTNAME, "ICT Fair Value Gap (FVG) MT5");
   return(INIT_SUCCEEDED);
}

How to Install & Compile in MetaTrader MT5

Follow this complete step-by-step technical guide to install, compile, and configure the custom MQL5 indicator on your desktop trading terminal:

Step 1

Download Source File

Download the raw .mq5 source file to your computer using the direct download button below.

Step 2

Open MT5 Data Folder

Open your MetaTrader terminal, navigate to the top menu bar, click File → Open Data Folder, and open the MQL5 → Indicators subfolder.

Step 3

Copy & Compile in MetaEditor

Paste the downloaded file into the Indicators directory. Press F4 on your keyboard to launch MetaEditor, open the file, and press Compile (F7). Ensure the compiler reports 0 errors and 0 warnings.

Step 4

Attach to Chart & Configure

Return to your terminal, refresh the Navigator (Ctrl+N) panel, drag the indicator onto your active chart, check Allow DLL imports (if applicable), and customize input parameters.

Integrating with Expert Advisors (EA) via iCustom()

Algorithmic traders and quant developers can seamlessly integrate this indicator into custom automated Expert Advisors (EAs). Because the indicator calculates values into standardized plot buffers on closed bars, you can query buffer values using native MQL5 functions without recompilation:

// MT5 MQL5 iCustom Calling Syntax Example
int indicatorHandle = iCustom(_Symbol, _Period, "FairValueGap_FVG_MT5");
double buyBuffer[1], sellBuffer[1];

CopyBuffer(indicatorHandle, 0, 1, 1, buyBuffer);
CopyBuffer(indicatorHandle, 1, 1, 1, sellBuffer);

if (buyBuffer[0] != 0.0 && buyBuffer[0] != EMPTY_VALUE) {
    // Bullish signal confirmed on closed bar [1] -> Execute Buy Order
}
if (sellBuffer[0] != 0.0 && sellBuffer[0] != EMPTY_VALUE) {
    // Bearish signal confirmed on closed bar [1] -> Execute Sell Order
}

How to Set Up Mobile Push Notifications on iOS & Android

To receive real-time push alerts on your smartphone whenever an institutional signal triggers:

  1. Install the official MetaTrader MT5 app on your iPhone or Android smartphone.
  2. Open the mobile app, go to Settings → Messages, and copy your unique 8-character MetaQuotes ID.
  3. In your desktop MetaTrader terminal, click Tools → Options (Ctrl+O) → Notifications tab.
  4. Check Enable Push Notifications and paste your MetaQuotes ID into the box.
  5. Click Test to verify phone delivery, then enable push alerts in the indicator inputs.

Institutional Risk Management & Capital Preservation Protocol

Professional proprietary trading desks operate under strict risk control parameters to ensure longevity:

  • Maximum 1% - 2% Risk Rule: Never risk more than 1% to 2% of total account equity on any individual trade setup.
  • Minimum 1:2.5 Risk-to-Reward Ratio (RRR): Only execute setups where the potential profit target is at least 2.5 times greater than the stop-loss invalidation distance.
  • Multi-Timeframe Confluence Required: Never take an intraday trade against the primary Daily or 4-Hour trend direction.
  • High-Impact Economic News Awareness: Avoid entering new positions 15 minutes before and after major macroeconomic data releases (such as US Non-Farm Payrolls, CPI Inflation, and central bank FOMC/ECB interest rate announcements).

Strategy Backtesting & Historical Modeling Protocol

Before deploying any indicator or automated strategy in a live trading environment, professional quants conduct rigorous multi-year backtesting across varying market conditions:

  • 99.9% Tick Data Modeling: Use high-precision tick history from reputable data providers (such as Dukascopy or TrueFX) to eliminate spread anomalies and slippage distortion.
  • Spread & Commission Inclusion: Always test with realistic variable spreads and broker commission structures to simulate true real-world execution friction.
  • Out-of-Sample Walk-Forward Optimization: Avoid curve-fitting by validating parameters on 70% in-sample data and testing robustness on 30% out-of-sample data.
  • Monte Carlo Drawdown Analysis: Run randomized trade sequence simulations to calculate the maximum potential drawdown under adverse market volatility regimes.

Virtual Private Server (VPS) & Execution Latency Optimization

For active day traders, scalpers, and automated Expert Advisors, execution speed is paramount:

  • Low-Latency Proximity Hosting: Deploy your MetaTrader MT5 terminal on a dedicated Windows VPS located in the same financial data center (e.g. Equinix LD4 in London or NY4 in New York) as your broker server to achieve sub-millisecond execution times.
  • Terminal Memory Optimization: Go to Tools → Options → Charts and decrease Max bars in chart to 5,000 to conserve CPU and RAM resources.
  • Audio & News Feed Disabling: Turn off unneeded terminal audio event chimes and background news feeds to ensure 100% of CPU cycles are dedicated to indicator calculations.

Common MetaTrader Error Codes & Resolution Matrix

Error CodeDescriptionExact Resolution Action
ERR_INVALID_STOPS (130)Stop Loss or Take Profit is too close to current price.Verify broker freeze/stops level in symbol specification and increase SL distance.
ERR_OFF_QUOTES (136)Broker server has no available liquidity quotes.Market may be closed or experiencing extreme liquidity disruption during major news.
ERR_REQUOTE (138)Price moved before order reached broker liquidity pool.Increase slippage tolerance deviation parameter in your order execution settings.
ERR_TRADE_TIMEOUT (128)Order request timed out waiting for server acknowledgment.Check internet connection latency or migrate terminal to a dedicated trading VPS.

Institutional Quantitative Trading Lexicon

Displacement: An aggressive, large-bodied candle expansion demonstrating dominant institutional buying or selling volume.
Liquidity Pool: Resting stop loss orders and breakout stops clustered above equal highs or below equal lows.
Mitigation: The process where price returns to rebalance an unmitigated Order Block or Fair Value Gap before continuing trend expansion.
Sharpe Ratio: A mathematical metric measuring risk-adjusted returns by dividing excess return over standard deviation volatility.

Broker Execution Models & Raw Spread Compatibility

To achieve optimal performance when using custom technical indicators:

  • ECN / Raw Spread Accounts: Use True ECN accounts with 0.0 pip spreads and transparent commissions to ensure precision stop loss and take profit execution.
  • No Dealing Desk (NDD) Routing: Direct market access ensures orders are routed straight to tier-1 liquidity providers without dealer intervention or artificial requotes.
  • Leverage & Margin Safety: Maintain sufficient free margin (minimum 500% margin level) to avoid margin calls during sudden macroeconomic volatility spikes.

FairValueGap_FVG_MT5.mq5

Version: v2.10File Size: 16.9 KBTotal Downloads: 15,000+License: Free Open SourcePlatform: MetaTrader MT5

Download .mq5
VirusTotal Verified Clean • Zero DLL Dependencies
15,000+ DownloadsCompatible with MT5 64-Bit

Frequently Asked Questions

Yes. Set InpPushAlerts to true to receive instant notifications on your iPhone or Android MetaTrader 5 app.
RaptozGroup
Developed & Audited by RaptozGroup

Quantitative algorithmic trading research desk specializing in MetaTrader MQL4/MQL5 automated systems, institutional order book mechanics, and risk management tools.

FairValueGap_FVG_MT5.mq5
15,000+ DownloadsFree Open Source
Download .mq5