OPEN-SOURCE SCRIPT
FVG / IFVG - ICT - 1H + 4H + Daily

Daily + 4H + 1H FVG / IFVG — Merged
This indicator provides a unified multi-timeframe inventory of Fair Value Gaps (FVGs) and Inverse Fair Value Gaps (IFVGs) from the Daily, 4-Hour, and 1-Hour source timeframes.
The purpose of the script is to make higher-timeframe imbalance structure directly visible on supported lower-timeframe charts while preserving the calculation and lifecycle logic of each source timeframe independently.
WHAT THE INDICATOR IDENTIFIES
The indicator uses strict three-candle FVG geometry.
Bullish FVG:
The low of the third source-timeframe candle must be above the high of the first source-timeframe candle.
The resulting zone extends from the first candle's high to the third candle's low.
Bearish FVG:
The high of the third source-timeframe candle must be below the low of the first source-timeframe candle.
The resulting zone extends from the third candle's high to the first candle's low.
Adjacent candle close/open gaps are not used in the calculation. The script evaluates the first-versus-third-candle price geometry directly.
SUPPORTED SOURCE TIMEFRAMES
The merged indicator contains three independent engines:
• Daily FVG / IFVG inventory
• 4H FVG / IFVG inventory
• 1H FVG / IFVG inventory
The Daily engine can be displayed on intraday and Daily charts.
The 4H engine operates on 4H and lower intraday charts.
The 1H engine operates on 1H and lower intraday charts.
Higher-timeframe calculations are based on confirmed source-timeframe information. On lower chart timeframes, previously completed higher-timeframe candles are used so that an unfinished higher-timeframe candle is not treated as a confirmed close.
CONFIRMED FVG → IFVG LIFECYCLE
The default lifecycle system does not convert an FVG immediately after a single opposing close.
For the Daily, 4H, and 1H engines, an original FVG becomes an opposite-direction IFVG only after two consecutive confirmed source-timeframe closes beyond the relevant FVG boundary.
Example:
A bullish FVG becomes a bearish IFVG after two consecutive confirmed source-timeframe closes below its lower boundary.
A bearish FVG becomes a bullish IFVG after two consecutive confirmed source-timeframe closes above its upper boundary.
This confirmation mechanism is intended to distinguish a temporary boundary violation from a confirmed structural inversion.
IFVG INVALIDATION
The indicator also manages the lifecycle of an IFVG after conversion.
For 4H zones, the number of consecutive reverse closes required for IFVG invalidation can be selected from 1 through 5.
For 1H zones, bullish and bearish IFVG invalidation thresholds can be configured independently, and confirmed IFVG invalidation can also be disabled.
The Daily confirmed-lifecycle model removes an IFVG after a confirmed Daily close through its opposite invalidation boundary.
PERSISTENT CURRENT-PRICE MODE
Each timeframe also provides an alternative persistent classification model.
When confirmed lifecycle mode is disabled, the original FVG remains in the inventory for the selected lookback period and is classified according to the current market-price relationship to the original zone.
In this mode:
• Price on the original/native side of the zone = original FVG classification
• Price beyond the opposite side = opposite-direction IFVG classification
• Price inside the zone = the most recently resolved classification remains active
This allows users to study the same original imbalance as its relationship with price evolves.
4H CONSECUTIVE-ZONE FILTERING
The 4H engine includes additional filtering for consecutive FVG and IFVG sequences.
When two or more same-direction FVGs occur on consecutive 4H source candles, the user can select which ordinal zone in the sequence is displayed:
1st, 2nd, 3rd, 4th, or 5th.
The same concept is available for consecutive 4H IFVG conversions.
Single isolated zones remain eligible for display.
This feature is designed for users who want to isolate a specific position within a sequence of higher-timeframe imbalances instead of displaying every zone in a cluster.
LOOKBACK AND INVENTORY CONTROL
Each timeframe has an independent calendar-day formation lookback.
Available selections are:
5, 10, 15, 30, 90, 180, or 365 calendar days.
Zones whose original formation falls outside the selected lookback are removed from that timeframe's active inventory.
MINIMUM FVG SIZE
Each source timeframe has an independent minimum FVG-size filter.
This allows the user to exclude gaps below a specified point size while retaining the same underlying three-candle detection logic.
MASTER VISIBILITY CONTROLS
The indicator includes a quick-control section for managing the entire chart without changing the underlying detection logic.
Users can globally enable or disable:
• All bullish zones
• All bearish zones
Each source timeframe also has independent controls for:
• Daily
• 4H
• 1H
• Bullish structures
• Bearish structures
Additional individual controls are available for bullish FVGs, bearish FVGs, bullish IFVGs, and bearish IFVGs.
These master switches control plotting and alert routing only. They do not modify the underlying source-timeframe calculations or zone lifecycle.
DYNAMIC ZONE PROJECTION
Visible zones extend dynamically to the opening timestamp of the current chart candle.
Users can also choose where the historical left edge of a zone begins:
• First FVG candle
• FVG end candle
The price boundaries themselves remain derived from the original FVG geometry.
ALERTS
The indicator includes alert conditions for both structure creation/classification and first interaction with visible zones.
Alerts are available for:
• Bullish FVG formation
• Bearish FVG formation
• Bullish IFVG classification
• Bearish IFVG classification
• Bullish FVG first retest
• Bearish FVG first retest
• Bullish IFVG first retest
• Bearish IFVG first retest
These alerts are implemented independently for the Daily, 4H, and 1H engines and respect the corresponding visibility and directional controls.
VISUAL CUSTOMIZATION
Each timeframe includes configurable visual parameters, including:
• Bullish zone color
• Bearish zone color
• FVG transparency
• IFVG transparency
• Border transparency
• Border width
• Zone text visibility
• Zone text color
FVG and IFVG states use distinct border styling to make their current classification easier to distinguish visually.
INTENDED USE
This indicator is intended as a market-structure and imbalance-mapping tool.
It can be used to:
• Monitor higher-timeframe FVGs while executing on lower timeframes
• Distinguish original FVGs from structurally inverted IFVGs
• Track confirmed higher-timeframe state changes
• Identify the first return of price to an active higher-timeframe zone
• Reduce chart clutter through directional, timeframe, size, lifecycle, and consecutive-zone filtering
The indicator does not generate an autonomous trading strategy, position sizing, entries, stop losses, profit targets, or performance projections.
FVG and IFVG zones should therefore be treated as structural market information rather than standalone trade recommendations.
IMPORTANT
Users should understand the distinction between Confirmed Lifecycle mode and Persistent Current-Price mode before using the indicator.
Confirmed Lifecycle mode requires completed source-timeframe closes to change structural state.
Persistent Current-Price mode intentionally allows classification to follow the current market-price relationship to the original gap and therefore represents a different analytical methodology.
The two modes should not be interpreted as producing identical historical or real-time behavior.
This script is intended for technical analysis and research purposes only and does not constitute financial advice.
This indicator provides a unified multi-timeframe inventory of Fair Value Gaps (FVGs) and Inverse Fair Value Gaps (IFVGs) from the Daily, 4-Hour, and 1-Hour source timeframes.
The purpose of the script is to make higher-timeframe imbalance structure directly visible on supported lower-timeframe charts while preserving the calculation and lifecycle logic of each source timeframe independently.
WHAT THE INDICATOR IDENTIFIES
The indicator uses strict three-candle FVG geometry.
Bullish FVG:
The low of the third source-timeframe candle must be above the high of the first source-timeframe candle.
The resulting zone extends from the first candle's high to the third candle's low.
Bearish FVG:
The high of the third source-timeframe candle must be below the low of the first source-timeframe candle.
The resulting zone extends from the third candle's high to the first candle's low.
Adjacent candle close/open gaps are not used in the calculation. The script evaluates the first-versus-third-candle price geometry directly.
SUPPORTED SOURCE TIMEFRAMES
The merged indicator contains three independent engines:
• Daily FVG / IFVG inventory
• 4H FVG / IFVG inventory
• 1H FVG / IFVG inventory
The Daily engine can be displayed on intraday and Daily charts.
The 4H engine operates on 4H and lower intraday charts.
The 1H engine operates on 1H and lower intraday charts.
Higher-timeframe calculations are based on confirmed source-timeframe information. On lower chart timeframes, previously completed higher-timeframe candles are used so that an unfinished higher-timeframe candle is not treated as a confirmed close.
CONFIRMED FVG → IFVG LIFECYCLE
The default lifecycle system does not convert an FVG immediately after a single opposing close.
For the Daily, 4H, and 1H engines, an original FVG becomes an opposite-direction IFVG only after two consecutive confirmed source-timeframe closes beyond the relevant FVG boundary.
Example:
A bullish FVG becomes a bearish IFVG after two consecutive confirmed source-timeframe closes below its lower boundary.
A bearish FVG becomes a bullish IFVG after two consecutive confirmed source-timeframe closes above its upper boundary.
This confirmation mechanism is intended to distinguish a temporary boundary violation from a confirmed structural inversion.
IFVG INVALIDATION
The indicator also manages the lifecycle of an IFVG after conversion.
For 4H zones, the number of consecutive reverse closes required for IFVG invalidation can be selected from 1 through 5.
For 1H zones, bullish and bearish IFVG invalidation thresholds can be configured independently, and confirmed IFVG invalidation can also be disabled.
The Daily confirmed-lifecycle model removes an IFVG after a confirmed Daily close through its opposite invalidation boundary.
PERSISTENT CURRENT-PRICE MODE
Each timeframe also provides an alternative persistent classification model.
When confirmed lifecycle mode is disabled, the original FVG remains in the inventory for the selected lookback period and is classified according to the current market-price relationship to the original zone.
In this mode:
• Price on the original/native side of the zone = original FVG classification
• Price beyond the opposite side = opposite-direction IFVG classification
• Price inside the zone = the most recently resolved classification remains active
This allows users to study the same original imbalance as its relationship with price evolves.
4H CONSECUTIVE-ZONE FILTERING
The 4H engine includes additional filtering for consecutive FVG and IFVG sequences.
When two or more same-direction FVGs occur on consecutive 4H source candles, the user can select which ordinal zone in the sequence is displayed:
1st, 2nd, 3rd, 4th, or 5th.
The same concept is available for consecutive 4H IFVG conversions.
Single isolated zones remain eligible for display.
This feature is designed for users who want to isolate a specific position within a sequence of higher-timeframe imbalances instead of displaying every zone in a cluster.
LOOKBACK AND INVENTORY CONTROL
Each timeframe has an independent calendar-day formation lookback.
Available selections are:
5, 10, 15, 30, 90, 180, or 365 calendar days.
Zones whose original formation falls outside the selected lookback are removed from that timeframe's active inventory.
MINIMUM FVG SIZE
Each source timeframe has an independent minimum FVG-size filter.
This allows the user to exclude gaps below a specified point size while retaining the same underlying three-candle detection logic.
MASTER VISIBILITY CONTROLS
The indicator includes a quick-control section for managing the entire chart without changing the underlying detection logic.
Users can globally enable or disable:
• All bullish zones
• All bearish zones
Each source timeframe also has independent controls for:
• Daily
• 4H
• 1H
• Bullish structures
• Bearish structures
Additional individual controls are available for bullish FVGs, bearish FVGs, bullish IFVGs, and bearish IFVGs.
These master switches control plotting and alert routing only. They do not modify the underlying source-timeframe calculations or zone lifecycle.
DYNAMIC ZONE PROJECTION
Visible zones extend dynamically to the opening timestamp of the current chart candle.
Users can also choose where the historical left edge of a zone begins:
• First FVG candle
• FVG end candle
The price boundaries themselves remain derived from the original FVG geometry.
ALERTS
The indicator includes alert conditions for both structure creation/classification and first interaction with visible zones.
Alerts are available for:
• Bullish FVG formation
• Bearish FVG formation
• Bullish IFVG classification
• Bearish IFVG classification
• Bullish FVG first retest
• Bearish FVG first retest
• Bullish IFVG first retest
• Bearish IFVG first retest
These alerts are implemented independently for the Daily, 4H, and 1H engines and respect the corresponding visibility and directional controls.
VISUAL CUSTOMIZATION
Each timeframe includes configurable visual parameters, including:
• Bullish zone color
• Bearish zone color
• FVG transparency
• IFVG transparency
• Border transparency
• Border width
• Zone text visibility
• Zone text color
FVG and IFVG states use distinct border styling to make their current classification easier to distinguish visually.
INTENDED USE
This indicator is intended as a market-structure and imbalance-mapping tool.
It can be used to:
• Monitor higher-timeframe FVGs while executing on lower timeframes
• Distinguish original FVGs from structurally inverted IFVGs
• Track confirmed higher-timeframe state changes
• Identify the first return of price to an active higher-timeframe zone
• Reduce chart clutter through directional, timeframe, size, lifecycle, and consecutive-zone filtering
The indicator does not generate an autonomous trading strategy, position sizing, entries, stop losses, profit targets, or performance projections.
FVG and IFVG zones should therefore be treated as structural market information rather than standalone trade recommendations.
IMPORTANT
Users should understand the distinction between Confirmed Lifecycle mode and Persistent Current-Price mode before using the indicator.
Confirmed Lifecycle mode requires completed source-timeframe closes to change structural state.
Persistent Current-Price mode intentionally allows classification to follow the current market-price relationship to the original gap and therefore represents a different analytical methodology.
The two modes should not be interpreted as producing identical historical or real-time behavior.
This script is intended for technical analysis and research purposes only and does not constitute financial advice.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。