OPEN-SOURCE SCRIPT
Atualizado

Time-Based Fair Value Gaps (FVG) with Inversions (iFVG)

3 394
Overview
The Time-Based Fair Value Gaps (FVG) with Inversions (iFVG) (ICT/SMT) indicator is a specialized tool designed for traders using Inner Circle Trader (ICT) methodologies. Inspired by LuxAlgo's Fair Value Gap indicator, this script introduces significant enhancements by integrating ICT principles, focusing on precise time-based FVG detection, inversion tracking, and retest signals tailored for institutional trading strategies. Unlike LuxAlgo’s general FVG approach, this indicator filters FVGs within customizable 10-minute windows aligned with ICT’s macro timeframes and incorporates ICT-specific concepts like mitigation, liquidity grabs, and session-based gap prioritization.

This tool is optimized for 1–5 minute charts, though probably best for 1 minute charts, identifying bullish and bearish FVGs, tracking their mitigation into inverted FVGs (iFVGs) as key support/resistance zones, and generating retest signals with customizable “Close” or “Wick” confirmation. Features like ATR-based filtering, optional FVG labels, mitigation removal, and session-specific FVG detection (e.g., first FVG in AM/PM sessions) make it a powerful tool for ICT traders.

Originality and Improvements
While inspired by LuxAlgo’s FVG indicator (credit to LuxAlgo for their foundational work), this script significantly extends the original concept by:
1. Time-Based FVG Detection: Unlike LuxAlgo’s continuous FVG identification, this script filters FVGs within user-defined 10-minute windows each hour (:00–:10, :10–:20, etc.), aligning with ICT’s emphasis on specific periods of institutional activity, such as hourly opens/closes or kill zones (e.g., New York 7:00–11:00 AM EST). This ensures FVGs are relevant to high-probability ICT setups.
2. Session-Specific First FVG Option: A unique feature allows traders to display only the first FVG in ICT-defined AM (9:30–10:00 AM EST) or PM (1:30–2:00 PM EST) sessions, reflecting ICT’s focus on initial market imbalances during key liquidity events.
3. ICT-Driven Mitigation and Inversion Logic: The script tracks FVG mitigation (when price closes through a gap) and converts mitigated FVGs into iFVGs, which serve as ICT-style support/resistance zones. This aligns with ICT’s view that mitigated gaps become critical reversal points, unlike LuxAlgo’s simpler gap display.
4. Customizable Retest Signals: Retest signals for iFVGs are configurable for “Close” (conservative, requiring candle body confirmation) or “Wick” (faster, using highs/lows), catering to ICT traders’ need for precise entry timing during liquidity grabs or Judas swings.
5. ATR Filtering and Mitigation Removal: An optional ATR filter ensures only significant FVGs are displayed, reducing noise, while mitigation removal declutters the chart by removing filled gaps, aligning with ICT’s principle that mitigated gaps lose relevance unless inverted.
6. Timezone and Timeframe Safeguards: A timezone offset setting aligns FVG detection with EST for ICT’s New York-centric strategies, and a timeframe warning alerts users to avoid ≥1-hour charts, ensuring accuracy in time-based filtering.
These enhancements make the script a distinct tool that builds on LuxAlgo’s foundation while offering ICT traders a tailored, high-precision solution.

How It Works

FVG Detection
FVGs are identified when a candle’s low is higher than the high of two candles prior (bullish FVG) or a candle’s high is lower than the low of two candles prior (bearish FVG). Detection is restricted to:
User-selected 10-minute windows (e.g., :00–:10, :50–:60) to capture ICT-relevant periods like hourly transitions.
AM/PM session first FVGs (if enabled), focusing on 9:30–10:00 AM or 1:30–2:00 PM EST for key market opens.

An optional ATR filter (default: 0.25× ATR) ensures only gaps larger than the threshold are displayed, prioritizing significant imbalances.

Mitigation and Inversion

When price closes through an FVG (e.g., below a bullish FVG’s bottom), the FVG is mitigated and becomes an iFVG, plotted as a support/resistance zone. iFVGs are critical in ICT for identifying reversal points where institutional orders accumulate.

Retest Signals
The script generates signals when price retests an iFVG:
Close: Triggers when the candle body confirms the retest (conservative, lower noise).
Wick: Triggers when the candle’s high/low touches the iFVG (faster, higher sensitivity). Signals are visualized with triangular markers (▲ for bullish, ▼ for bearish) and can trigger alerts.


Visualization
FVGs: Displayed as colored boxes (green for bullish, red for bearish) with optional “Bull FVG”/“Bear FVG” labels.
iFVGs: Shown as extended boxes with dashed midlines, limited to the user-defined number of recent zones (default: 5).
• Mitigation Removal: Mitigated FVGs/iFVGs are removed (if enabled) to keep the chart clean.

How to Use

Recommended Settings
Timeframe: Use 1–5 minute charts for precision, avoiding ≥1-hour timeframes (a warning label appears if misconfigured).
Time Windows: Enable :00–:10 and :50–:60 for hourly open/close FVGs, or use the “Show only 1st presented FVG” option for AM/PM session focus.
ATR Filter: Keep enabled (multiplier 0.25–0.5) for significant gaps; disable on 1-minute charts for more FVGs during volatility.
Signal Preference: Use “Close” for conservative entries, “Wick” for aggressive setups.
Timezone Offset: Set to -5 for EST (or -4 for EDT) to align with ICT’s New York session.

Trading Strategy
1. Macro Timeframes: Focus on New York (7:00–11:00 AM EST) or London (2:00–5:00 AM EST) kill zones for high institutional activity.
2. FVG Entries: Trade bullish FVGs as support in uptrends or bearish FVGs as resistance in downtrends, especially in :00–:10 or :50–:60 windows.
3. iFVG Retests: Enter on retest signals (▲/▼) during liquidity grabs or Judas swings, using “Close” for confirmation or “Wick” for speed.
4. Session FVGs: Use the “Show only 1st presented FVG” option to target the first gap in AM/PM sessions, often tied to ICT’s market maker algorithms.
5. Risk Management: Combine with ICT concepts like order blocks or breaker blocks for confluence, and set stops beyond FVG/iFVG boundaries.

Alerts


Set alerts for:
“Bullish FVG Detected”/“Bearish FVG Detected”: New FVGs in selected windows.
“Bullish Signal”/“Bearish Signal”: iFVG retest confirmations.
Settings Description
Show Last (1–100, default: 5): Number of recent iFVGs to display. Lower values reduce clutter.
Show only 1st presented FVG: Limits FVGs to the first in 9:30–10:00 AM or 1:30–2:00 PM EST sessions (overrides time window checkboxes).
Time Window Checkboxes: Enable/disable FVG detection in 10-minute windows (:00–:10, :10–:20, etc.). All enabled by default.
Signal Preference: “Close” (default) or “Wick” for iFVG retest signals.
Use ATR Filter: Enables ATR-based size filtering (default: true).
ATR Multiplier (0–∞, default: 0.25): Sets FVG size threshold (higher values = larger gaps).
Remove Mitigated FVGs: Removes filled FVGs/iFVGs (default: true).
Show FVG Labels: Displays “Bull FVG”/“Bear FVG” labels (default: true).
Timezone Offset (-12 to 12, default: -5): Aligns time windows with EST.
Colors: Customize bullish (green), bearish (red), and midline (gray) colors.

Why Use This Indicator?
This indicator empowers ICT traders with a tool that goes beyond generic FVG detection, offering precise, time-filtered gaps and inversion tracking aligned with institutional trading principles. By focusing on ICT’s macro timeframes, session-specific imbalances, and customizable signal logic, it provides a clear edge for scalping, swing trading, or reversal setups in high-liquidity markets.

Notas de Lançamento
Updated code to properly identify first FVG in AM and PM session.
Notas de Lançamento
Script has been updated to add labels to each FVG indicating date and time of the FVG. This is most beneficial for the "first presented FVG", which will identify the first FVG in the AM and PM sessions (after 0930 and 1330 EST, respectively). These FVGs can be valid for multiple days.

To best view historical first FVGs, turn on the option in settings, then turn off "remove mitigated" and "ATR". You will then see the first AM and PM FVGs on your chart, which will serve as support and resistance, as well as hint at near term direction once broken up or down.
Notas de Lançamento
One more code tweak to ensure the first presented FVG occurs on/after the 0931 candle, as the 0930 candle is not considered due to its absence in electronic trading hours.

Also changed the default UTC offset to -4 since eastern is in daylight saving time currently. This UTC will need adjusted for your location.

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.