OPEN-SOURCE SCRIPT
FVG Imbalance Tracker TGFX

FVG Imbalance Tracker
OVERVIEW
FVG Imbalance Tracker automatically detects, draws and tracks Fair Value Gaps (FVG), also known as imbalances. It marks each gap as a zone, extends it until price returns, and tells you when the gap has been mitigated (filled). An optional 50% midline (Consequent Encroachment / CE) and a higher-timeframe table give you context at a glance.
WHAT IS A FAIR VALUE GAP
A Fair Value Gap is a three-candle pattern where the first and third candles do not overlap, leaving a price range that was crossed in a single, one-sided move:
- Bullish FVG: the low of candle 3 is above the high of candle 1.
- Bearish FVG: the high of candle 3 is below the low of candle 1.
That untraded range is an imbalance. Price frequently returns to it later to "rebalance" before continuing, which is why these zones are useful as potential reaction areas.
HOW IT WORKS
1. On the close of every third candle, the script checks for a gap between candle 1 and candle 3.
2. If a gap is found (and passes the optional ATR size filter), a zone is drawn from the pattern to the right.
3. Each zone keeps extending until it is mitigated. You choose what mitigation means:
- Full fill: price fully closes the gap.
- 50% (CE): price reaches the midpoint (Consequent Encroachment).
- Touch: price reaches the near edge of the gap.
4. Once mitigated, the zone is dimmed and stops extending (or is removed, if you prefer).
HOW TO READ IT
- Green zones = bullish Fair Value Gaps (potential demand / support areas).
- Red zones = bearish Fair Value Gaps (potential supply / resistance areas).
- Solid, extending zone = still unmitigated.
- Dimmed zone = already mitigated.
- Dotted midline = the 50% (CE) level of the gap.
- Multi-timeframe table: shows the latest imbalance direction on three higher timeframes (Bull / Bear / –) for higher-timeframe context.
SETTINGS
- Detection: optional ATR filter to ignore small gaps, ATR length, minimum gap size (× ATR), and maximum gaps kept per side.
- Mitigation: choose Full fill, 50% (CE) or Touch, and whether mitigated gaps stay dimmed or are removed.
- Visual: colors for bullish/bearish gaps, box transparency, optional border, optional 50% midline, optional labels, label size.
- Multi-timeframe table: enable/disable, the three timeframes, and table position.
REPAINTING
Gaps are confirmed on the close of the third candle, so a zone does not appear and then disappear intrabar.
ALERTS
Three alerts are available: "New bullish FVG", "New bearish FVG" and "FVG mitigated". Add them from the alert dialog and set them to trigger once per bar close.
NOTES
This script is an original implementation of standard, public price-action concepts (Fair Value Gaps and Consequent Encroachment). It is a visualization and context tool — it does not generate buy/sell signals and makes no claim about future performance. Fair Value Gaps work best combined with your own analysis (market structure, liquidity, higher-timeframe context, risk management) rather than used in isolation.
OVERVIEW
FVG Imbalance Tracker automatically detects, draws and tracks Fair Value Gaps (FVG), also known as imbalances. It marks each gap as a zone, extends it until price returns, and tells you when the gap has been mitigated (filled). An optional 50% midline (Consequent Encroachment / CE) and a higher-timeframe table give you context at a glance.
WHAT IS A FAIR VALUE GAP
A Fair Value Gap is a three-candle pattern where the first and third candles do not overlap, leaving a price range that was crossed in a single, one-sided move:
- Bullish FVG: the low of candle 3 is above the high of candle 1.
- Bearish FVG: the high of candle 3 is below the low of candle 1.
That untraded range is an imbalance. Price frequently returns to it later to "rebalance" before continuing, which is why these zones are useful as potential reaction areas.
HOW IT WORKS
1. On the close of every third candle, the script checks for a gap between candle 1 and candle 3.
2. If a gap is found (and passes the optional ATR size filter), a zone is drawn from the pattern to the right.
3. Each zone keeps extending until it is mitigated. You choose what mitigation means:
- Full fill: price fully closes the gap.
- 50% (CE): price reaches the midpoint (Consequent Encroachment).
- Touch: price reaches the near edge of the gap.
4. Once mitigated, the zone is dimmed and stops extending (or is removed, if you prefer).
HOW TO READ IT
- Green zones = bullish Fair Value Gaps (potential demand / support areas).
- Red zones = bearish Fair Value Gaps (potential supply / resistance areas).
- Solid, extending zone = still unmitigated.
- Dimmed zone = already mitigated.
- Dotted midline = the 50% (CE) level of the gap.
- Multi-timeframe table: shows the latest imbalance direction on three higher timeframes (Bull / Bear / –) for higher-timeframe context.
SETTINGS
- Detection: optional ATR filter to ignore small gaps, ATR length, minimum gap size (× ATR), and maximum gaps kept per side.
- Mitigation: choose Full fill, 50% (CE) or Touch, and whether mitigated gaps stay dimmed or are removed.
- Visual: colors for bullish/bearish gaps, box transparency, optional border, optional 50% midline, optional labels, label size.
- Multi-timeframe table: enable/disable, the three timeframes, and table position.
REPAINTING
Gaps are confirmed on the close of the third candle, so a zone does not appear and then disappear intrabar.
ALERTS
Three alerts are available: "New bullish FVG", "New bearish FVG" and "FVG mitigated". Add them from the alert dialog and set them to trigger once per bar close.
NOTES
This script is an original implementation of standard, public price-action concepts (Fair Value Gaps and Consequent Encroachment). It is a visualization and context tool — it does not generate buy/sell signals and makes no claim about future performance. Fair Value Gaps work best combined with your own analysis (market structure, liquidity, higher-timeframe context, risk management) rather than used in isolation.
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。