OPEN-SOURCE SCRIPT

Inversion Fair Value Gaps [iFVG] (Zeiierman)

3 284
Overview
Inversion Fair Value Gaps [iFVG] (Zeiierman) identifies when traditional Fair Value Gaps (FVGs) fail and transition into powerful inversion zones.

A regular Fair Value Gap represents an imbalance where price moved aggressively in one direction, leaving behind inefficient trading. While many traders expect these gaps to act as support or resistance, not every imbalance survives. Some are broken, absorbed, and eventually become areas where the opposite side of the market gains control.

This indicator continuously tracks every valid bullish and bearish FVG. When price successfully closes through an existing FVG and later forms an opposing FVG within the user-defined pairing window, the overlapping imbalance is converted into an Inversion Fair Value Gap (iFVG).

Rather than treating every FVG equally, the indicator focuses on failed imbalances that demonstrate a genuine shift in market order flow.
syot kilat
FVG Detection
The indicator continuously scans price using the classic three-candle Fair Value Gap model.

A Bullish FVG forms when:
• Price leaves an upside imbalance.
• The third candle creates a gap above the first candle.
syot kilat
A Bearish FVG forms when:
• Price leaves a downside imbalance.
• The third candle creates a gap below the first candle.
syot kilat
Unlike many FVG indicators, every detected gap remains internally tracked so it can later evolve into an inversion.

Inversion Fair Value Gap Detection
Once an FVG is created, it enters an internal memory system.

If price later closes completely through that imbalance, the FVG is considered broken. Rather than immediately discarding it, the indicator temporarily remembers the remaining imbalance.

If an opposing FVG forms before the memory expires, both structures are combined into a new Inversion Fair Value Gap.

Bullish iFVG

• Bearish FVG is broken.
• Bullish FVG forms shortly afterwards.
• The overlapping imbalance becomes bullish support.
syot kilat
Bearish iFVG

• Bullish FVG is broken.
• Bearish FVG forms shortly afterwards.
• The overlapping imbalance becomes bearish resistance.
syot kilat
This process filters out many ordinary FVGs and highlights only those that demonstrate a meaningful transition in buying or selling pressure.

How It Works

Fair Value Gap Detection
The script continuously searches for valid bullish and bearish three-candle imbalances.

Each detected FVG is validated using:

• Minimum gap size.
• Optional fractal confirmation.
• ATR-based filtering.

Only valid gaps enter the internal tracking system.
Pine Script®

Memory & Inversion Detection
Every valid FVG is stored until one of two events occurs:

• Price never breaks the gap, and it eventually expires.
• Price breaks the gap and an opposing FVG forms before the pairing window ends.

When both conditions are satisfied, the overlapping imbalance becomes a confirmed iFVG. This allows the indicator to detect genuine reversals rather than simply highlighting every imbalance.

Zone Management
Each zone continuously updates its internal state.

A zone may transition through several stages:

• Active
• Tested
• Mitigated
• Frozen
• Removed

Depending on user settings, mitigated zones can either disappear or remain on the chart as historical context.

Dynamic Zone Merging
Nearby live zones of the same direction can optionally be merged into a single visual area. This reduces chart clutter while preserving the original internal detection logic. The merged display affects visualization only.

Distance Filtering
Charts containing hundreds of historical zones can quickly become difficult to read.

The indicator can automatically hide zones that are farther than a user-defined ATR distance from the current price. Hidden zones continue to exist internally and become visible again if price returns. This improves chart clarity without affecting detection, memory, or alerts.

How to Use

Bullish iFVG Retest
After a bullish iFVG forms, price retraces back into the inversion zone before finding support and continuing higher.

Rather than chasing the initial breakout, traders can wait for the retest and look for long confirmation as price reacts from the bullish iFVG.
syot kilat
Bearish iFVG Retest
After a bearish iFVG forms, price retraces back into the inversion zone before finding resistance and continuing lower.

Instead of entering during the initial breakdown, traders can wait for the retest and look for short confirmation as price reacts from the bearish iFVG.
syot kilat
Settings
  • Minimum FVG Size: Minimum ATR-adjusted size required before a Fair Value Gap is accepted.
  • Enable Fractal Filter: Requires FVGs to form near confirmed swing highs or lows.
  • Fractal Length: Controls how large a swing must be before it is confirmed.
  • Maximum Distance From FVG: Maximum allowed distance between the confirmed swing and the FVG.
  • Pairing Window: Number of bars a broken FVG remains eligible to form an iFVG.
  • Delete Mitigated Zones: Removes mitigated zones or freezes them as historical references.
  • Mitigation Level: Select whether mitigation occurs at the 50% level or after a full fill.
  • Mitigation Source: Uses wick touches or candle closes to confirm mitigation.
  • Filter Distant Zones: Hides zones that are far away from the current price.
  • Maximum Distance From Price: Maximum ATR distance before zones become hidden.
  • Merge Nearby Zones: Visually combines nearby live zones of the same type.
  • Maximum Merge Distance: Controls how close zones must be before they merge visually.
  • Fade With Age: Gradually fades older zones while keeping newer zones more prominent.

-----------------
Disclaimer

The content provided in my scripts, indicators, ideas, algorithms, and systems is for educational and informational purposes only. It does not constitute financial advice, investment recommendations, or a solicitation to buy or sell any financial instruments. I will not accept liability for any loss or damage, including without limitation any loss of profit, which may arise directly or indirectly from the use of or reliance on such information.

All investments involve risk, and the past performance of a security, industry, sector, market, financial product, trading strategy, backtest, or individual's trading does not guarantee future results or returns. Investors are fully responsible for any investment decisions they make. Such decisions should be based solely on an evaluation of their financial circumstances, investment objectives, risk tolerance, and liquidity needs.

Penafian

Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.