Fair Value Gap (FVG) Detector with Auto-Removal
Info
The Fair Value Gap (FVG) Detector with Auto-Removal is a Indicator for MetaTrader 5 that fair value gap (fvg) detector with auto-removal concept of fair value gap a fair value gap, or fvg, represents a price imbalance created by a rapid price movement. It is identified by three consecutive candles where the first and third candles' price ranges do not overlap.
Usage
This tool is typically used for enhancing chart analysis and decision making.
Platform
This Indicator works exclusively on MetaTrader 5 (both build 600+ and newer versions).
Setup
Place the downloaded file in MQL5/Indicators folder via File ? Open Data Folder in MetaTrader 5.
How to Install and Use Fair Value Gap (FVG) Detector with Auto-Removal
1. Installation: Place your file in the MQL/Indicators folder via "Open Data Folder" and restart your terminal.
2. Loading: Find the indicator in the Navigator, drag it onto your chart, and configure the input parameters in the popup window.
3. Customization: Press Ctrl+I to open the indicator list, select your tool, and click "Properties" to change colors, levels, or visual styles.
4. Updating: Replace the old file in the Indicators folder with the new version and restart the platform to apply changes.
Frequently Asked Questions
Q: Why is my indicator not showing? A: Verify the file is in the MQL/Indicators folder, or try right-clicking the "Indicators" tree in the Navigator and clicking "Refresh."
Q: Do custom indicators slow down the platform? A: Too many complex indicators can impact performance; remove unused ones via the "Indicator List" (Ctrl+I).
Q: Can I use MT4 indicators on MT5? A: No, MQL4 and MQL5 are distinct languages; ensure the indicator is compiled specifically for your platform version.
What this tool does
Fair Value Gap (FVG) Detector with Auto-Removal Concept of Fair Value Gap A Fair Value Gap, or FVG, represents a price imbalance created by a rapid price movement.
Typical Use Case
This Indicator excels in automated trading and technical analysis on MetaTrader 5.
Compatible Platform & Setup
This Indicator works on MetaTrader 5. Place the file in the MQL5/Indicators folder and restart the terminal.
Description & Settings
Related: Daily Point of Control (POC) and Value Area Lines - another powerful indicator for MetaTrader 5 traders.
Fair Value Gap (FVG) Detector with Auto-Removal Concept of Fair Value Gap A Fair Value Gap, or FVG, represents a price imbalance created by a rapid price movement. It is identified by three consecutive candles where the first and third candles' price ranges do not overlap. The middle candle's range is where this gap occurred. Traders often anticipate the price returning to fill these gaps, utilizing them as potential entry or target zones, or as indicators of strong momentum. Bullish FVG - Defined when the Low of the third candle is higher than the High of the first candle. The gap is the price range between these two levels. Bearish FVG - Defined when the High of the third candle is lower than the Low of the first candle. The gap is the price range between these two levels. Indicator Functionality The indicator detects these gaps on completed bars, visually representing each FVG with a box. It continuously monitors active gaps and removes their boxes when they are filled, based on user-defined criteria. The chart thus displays only currently unfilled gaps. The indicator maintains a list of active gaps. Initially, it scans a specified number of past bars. Subsequently, each new completed bar is processed once, and incoming ticks are used solely to check active gaps against the current price action. The historical data is not rescanned after initialization. Interpreting the Indicator White Box (Default) - Indicates an unfilled bullish gap. It spans from the first candle of the FVG pattern to the right. A price retracement from above into this zone may act as a support level. Gray Box (Default) - Represents an unfilled bearish gap. When the price retraces from below into this zone, it may act as a resistance level. Box Edges - The top and bottom boundaries of a box represent the high and low prices of the identified gap. Hovering over a box displays its type and size in points. Disappearing Boxes - When price action fills a gap, its corresponding box is removed. If the `InpDeleteFilled` input is set to false, filled gaps may remain visible as gray dotted boxes, extending only up to the bar where the fill occurred. Visual Cues Large boxes suggest strong, unidirectional price movements. The presence of numerous open boxes on one side of the price action can indicate persistent market imbalance. Fill Rule Options The definition of a "filled" gap is configurable via the `InpFillMode` input: FVG_FILL_TOUCH - A gap is considered filled as soon as the price enters its range. FVG_FILL_HALF - A gap is considered filled when the price reaches the midpoint of the gap range. FVG_FILL_FULL - A gap is considered filled only when the price completely traverses the gap range (default setting). The fill check utilizes the High and Low prices (wicks) of bars subsequent to the FVG pattern formation. External Variables (Inputs) Input Name | Default Value | Purpose ---|---|--- Detection InpMinGapPoints | 10 | Minimum gap size in points to be considered. Smaller gaps are ignored. Set to 0 to consider gaps of any size. InpLookbackBars | 500 | Number of historical bars to scan upon indicator initialization (range: 10 to 5000). InpMaxZones | 30 | Maximum number of FVG zones to display simultaneously. Older zones are removed when this limit is reached (range: 1 to 200). Fill Rule InpFillMode | FVG_FILL_FULL | Defines the condition for a gap being considered filled: FVG_FILL_TOUCH, FVG_FILL_HALF, or FVG_FILL_FULL. InpDeleteFilled | true | Determines whether filled zones are removed (true) or remain visible as dotted boxes (false). InpFilledColor | clrDimGray | Color used for displaying filled zones when `InpDeleteFilled` is false. Appearance InpBullColor | clrWhite | Color for bullish FVG boxes. InpBearColor | clrGray | Color for bearish FVG boxes. InpZoneStyle | STYLE_DASH | Border style for the FVG boxes. InpZoneWidth | 1 | Width of the FVG box border (range: 1 to 5). InpFillZones | false | Option to fill the FVG boxes with their respective colors. InpExtendBars | 20 | Number of bars to the right of the last bar that FVG boxes will extend (range: 0 to 200). Alerts InpAlertNew | false | Enables alerts when a new FVG forms on a completed bar. Recommended Usage This indicator is effective on any trading symbol and timeframe. FVGs tend to be more significant on liquid markets and timeframes ranging from M5 to H4. On very short timeframes, the frequency of gaps increases; consider increasing `InpMinGapPoints` in such cases. Adjust `InpMinGapPoints` based on the specific symbol's volatility. For a 5-digit Forex symbol, a value of 10 points translates to 1 pip, which is minimal. Metals and indices typically require significantly larger point values. FVGs are identified exclusively on closed bars. Therefore, a gap will not appear or disappear while the third candle of the pattern is still forming. A gap is confirmed and displayed only when its third candle closes. Upon initial loading, the indicator scans the last `InpLookbackBars` bars. Consequently, very old gaps may not be displayed. Filled gaps are removed promptly, meaning that after a restart, only open gaps within the scanned history will be visible. To maintain chart clarity, when the number of open gaps exceeds `InpMaxZones`, the oldest gaps are automatically removed. Gaps occurring between bars due to weekend or session breaks are treated as standard gaps if they meet the pattern criteria. It is important to remember that a gap is a price action concept, not a direct trading signal. It should be used in conjunction with trend analysis, structural information, or higher timeframe context. All graphical objects created by the indicator are prefixed with `Fvg_` and are automatically deleted when the indicator is removed from the chart. Avoid attaching multiple instances of this indicator to the same chart, as this can lead to object name conflicts. As this is a chart indicator and does not execute trades, its functionality is consistent across both netting and hedging account types. Figure 1. FVG Detector on an M15 chart using default settings, illustrating open bullish gaps in white and a bearish gap in gray.Also recommended: Support/Resistance and Fair Value Gap Zones - similar indicator with strong performance on MetaTrader 5.
You may also like: Fair Value Gap (FVG) Detector with Auto-Removal When Filled (2026 Update) - excellent alternative for indicator users on MetaTrader 5.
Source Code
#property copyright "RobotFX"
#property link "https://robotfx.org"
#property version "1.00"
#property description "This code is educational. Feel free to use, modify and upgrade as you wish. Visit ROBOTFX.ORG for professional trading tools"
#property indicator_chart_window
#property indicator_plots 0
enum ENUM_FVG_FILL
{
FVG_FILL_TOUCH,
FVG_FILL_HALF,
.......
⚠ Limitations & Risk Warning
- This tool is provided for educational and testing purposes only.
- Past performance does not guarantee future results.
- Trading involves substantial risk of loss. Use on a demo account first.
- Results may vary depending on market conditions, broker, and settings.
- We recommend thorough backtesting and forward testing before using with real funds.