Fair Value Gap Zone
- Indicators
- Mattia Impicciatore
- Version: 1.0
General Description
The Fair Gap Value Indicator identifies and highlights “fair value gaps” on the MetaTrader 5 chart. A fair gap occurs when a price void forms between the low of one bar and the high of another, separated by an intermediate bar. The indicator draws colored rectangles (bullish and bearish) to emphasize these areas, providing clear visual support for price-action strategies.
Key Features
-
Bullish Gap Detection: highlights gaps between a bar’s low and the high of two bars prior with green rectangles.
-
Bearish Gap Detection: highlights inverse gaps with red rectangles.
-
Dynamic Extension: ability to extend rectangles by a variable number of bars to the right.
-
Transparency Control: configurable opacity level to avoid obscuring the underlying chart.
-
Toggle Flags: options to enable or disable bullish and bearish gap plotting separately.
-
Historical Limit: optional limit on the number of bars scanned to improve performance on large datasets.
-
Automatic Cleanup: on timeframe change or first load, all previous gaps are removed and recreated.
Input Parameters
-
LookbackBars: number of bars to look back for gap calculation (default 3).
-
MaxBars: maximum number of bars to scan (0 = no limit; default 0).
-
ShowBullGaps: enable/disable bullish gap plotting (default true).
-
ShowBearGaps: enable/disable bearish gap plotting (default true).
-
BullGapColor: color for bullish gaps (default green).
-
BearGapColor: color for bearish gaps (default red).
-
GapTransparency: rectangle transparency (0 = fully opaque, 255 = invisible; default 70).
-
MinGapPips: minimum gap size in pips to consider (default 10).
-
ExtendBars: additional bars to extend rectangles to the right (default 0).
How It Works
-
Initialization: configures the buffer and removes any existing gap objects.
-
Scanning: for each bar (within the MaxBars limit), computes the up-gap (low minus high) and down-gap (vice versa).
-
Threshold Check: considers only gaps with size ≥ MinGapPips .
-
Rectangle Creation: draws rectangles from the start point to the number of bars defined by ExtendBars , applying color and transparency.
-
Updating: on timeframe change or first run, clears and redraws all gaps to ensure consistency.
Advantages
-
Visual Clarity: quickly identifies potential areas of interest.
-
Flexibility: separate controls for gap type, color, transparency, extension, and historical range.
-
Efficiency: automatic object management and optional bar limit to preserve performance.
Usage Tips
Combine the indicator with volume or trend filters to confirm gap validity. Adjust MaxBars and ExtendBars according to your timeframe and instrument volatility.
