Inversion Fair Value Gaps IFVG
- Indicadores
- Versão: 1.0
- Ativações: 5
## What is an Inversion Fair Value Gap?
A **Fair Value Gap (FVG)** is a three-candle imbalance where price moves so fast that a price range is left untested. When price later returns and **closes through** that zone rather than respecting it, the imbalance *inverts* — what was support becomes resistance, or vice versa. This flipped zone is called an **Inversion Fair Value Gap (IFVG)**.
IFVGs are a core concept in modern Smart Money and ICT-derived analysis. They represent points where institutional order flow has demonstrably changed character, making them high-probability areas for price reaction on subsequent retests.
---
## The Formula
**Step 1 — Detect FVG:**
A bullish FVG exists when `Low[i] > High[i-2]` (gap between candle i and candle i-2, with candle i-1 as the impulse body). A bearish FVG exists when `High[i-2] < Low[i]` (inverted gap).
Gap size is filtered by: `min_gap = min(ATR(200) × multiplier, price × 0.01%)` — this hybrid filter prevents over-filtering on instruments with wide spreads while still rejecting noise.
**Step 2 — Detect Inversion:**
A bullish FVG *inverts* when price touches the zone AND **closes below** the FVG bottom. A bearish FVG inverts when price touches AND **closes above** the FVG top. The touch condition can be set to use close/body (default) or wick.
**Step 3 — Signal on Retest:**
Once inverted, the IFVG zone remains active. Every subsequent bar that touches and breaks through the zone in the inversion direction generates a triangle signal (▲ bullish / ▼ bearish) and fires the configured alert.
**Step 4 — Mitigation:**
An IFVG is mitigated (closed) when price closes on the opposite side of the entire zone, confirming the structure is no longer valid.
---
## Why this implementation is different
Most FVG indicators only draw the original gap. This indicator adds the full IFVG lifecycle:
- **Two-part visual**: The box is split at the inversion candle — the left section (original FVG color) shows where the gap formed; the right section (inverted color) shows the active zone going forward. You see the full story at a glance.
- **Midline on every zone**: Optional dashed midline marks the 50% level of each IFVG — the most common reaction point for scalpers.
- **Signal triangles**: Plotted directly at the reaction price, not offset. No guesswork about where the signal fired.
- **Smart alerts**: Alerts fire only on the **closed** bar of the prior period — never during bar formation, never on historical bars after attachment. Zero repeated alerts for the same candle.
- **ATR hybrid filter**: Combines a 200-period ATR multiplier with a minimum percentage-of-price floor so the sensitivity adapts to instrument volatility automatically.
- **Optional raw FVG layer**: Toggle `DrawFVG = true` to see the unflipped gaps in the pipeline alongside the active IFVGs — useful for anticipating the next inversion.
---
## Key parameters
| Parameter | Default | Description |
|---|---|---|
| Show Last Pairs | 5 | Number of active bull + bear IFVG pairs to display (1–100) |
| Signal Preference | Close | Body close vs wick touch for inversion / retest detection |
| ATR Multiplier | 0.25 | Scales the ATR-based minimum gap filter (0.0–10.0) |
| Transparency | 60 | Zone fill opacity, 0 = solid, 100 = invisible |
| Bull Color | Gold | Color of bullish IFVG zones (and original bull FVGs) |
| Bear Color | Blue-violet | Color of bearish IFVG zones (and original bear FVGs) |
| Bull FVG Color | Lime | Color for raw (uninverted) bullish FVG display |
| Bear FVG Color | Magenta | Color for raw (uninverted) bearish FVG display |
| Midline Color | Gray | Color of the 50% midline dashes |
| Line Style | Dot | Style of midlines: Dot, Dash, DashDot, Solid |
| Draw FVG | false | Show the underlying uninverted FVG boxes |
| Draw Midline FVG | true | Show midline on raw FVG boxes |
| Draw Midline IFVG | true | Show midline on IFVG boxes |
| Show Signals | true | Plot ▲ / ▼ triangles on retest entries |
| Bars to Process | 5000 | Historical look-back depth |
| Enable Alerts | true | Master switch for all alert types |
| Alert Popup | false | MT5 pop-up alert dialog |
| Alert Sound | false | Audio alert (configurable WAV file) |
| Alert Email | false | Email notification (requires MT5 email config) |
| Alert Push | true | Mobile push notification |
---
## Compatibility
- MetaTrader 5 (build 2700+)
- Any symbol — optimized and tested on XAUUSD
- Any timeframe M1 to W1
- Recommended: M5 or H1 for intraday XAUUSD scalping and swing trading
---
## How to use
1. Attach to any chart. Default settings are tuned for XAUUSD M5/H1.
2. Gold zones (bullish IFVG) act as potential **support** on retest — look for ▲ signals.
3. Blue-violet zones (bearish IFVG) act as potential **resistance** on retest — look for ▼ signals.
4. The midline (50%) is the first reaction target inside the zone.
5. A zone is invalidated when price closes fully through it — remove it from your bias.
6. Enable Push notifications to receive alerts on your MT5 mobile app the moment a closed bar fires a signal.
---
*Trading involves risk. This indicator is a decision-support tool, not a trading system. Past performance does not guarantee future results.*
