OPEN-SOURCE SCRIPT
Pure FVG [Textbook]

1. The Core Concept
This is not a standard "show all gaps" indicator. It is a specific entry signal generator based on Smart Money Concepts (SMC).
It focuses on Consequent Encroachment (The 50% Level). The underlying principle is that a Fair Value Gap (FVG) represents a market inefficiency where opposing traders are trapped. When price retraces at least 50% back into this gap, it creates pressure as these trapped positions look to exit—either through stop-losses or position reversal. This makes the gap most likely to act as a reversal zone.
2. How It Works (The Lifecycle)
The indicator logic follows a strict sequence of events. A signal is generated only if all conditions are met in order:
-- Phase 1: Identification (The Fresh Gap)
The script scans for the classic 3-candle FVG pattern (where the 1st and 3rd candles do not overlap).
Visual: It draws a box (Green for Bullish, Red for Bearish) extending to the right.
The 50% Line: A dashed line is drawn through the center of the gap.
-- Phase 2: Mitigation (The Gray Zone)
This is the critical filter. The indicator waits for a candle to CLOSE past the 50% dashed line.
Once this happens, the gap is considered "Deeply Mitigated."
Visual: The box changes color to Gray. This tells the trader: "Price is deep in the zone, watch for a reaction."
-- Phase 3: The Signal (Rejection)
Once the box is Gray, the script watches for a "Rejection Candle."
Bullish Scenario: Price is deep in the gap (Gray). The script waits for a candle to close higher than it opened (a green candle).
Bearish Scenario: Price is deep in the gap (Gray). The script waits for a candle to close lower than it opened (a red candle).
Visual: A Triangle Label (▲ or ▼) appears, signaling an entry.
-- Phase 4: Invalidation
If the price closes completely past the far edge of the box (the Stop Loss level), the box is deleted immediately.
3. Key Options
These are the most important settings for the user:
-- Min Gap Size (%):
Filters out "noise." It ensures the script ignores tiny, insignificant gaps that are less than X% in height.
-- Max Visible Gaps:
Keeps your chart clean. It limits how many open boxes can be on the screen at once (e.g., only show the last 3 unclosed gaps).
-- Show Signal History Only:
Feature Highlight: When enabled, this hides all the "noise" of open or failed gaps. It only draws the boxes that successfully produced a Rejection Signal in the past.
This is not a standard "show all gaps" indicator. It is a specific entry signal generator based on Smart Money Concepts (SMC).
It focuses on Consequent Encroachment (The 50% Level). The underlying principle is that a Fair Value Gap (FVG) represents a market inefficiency where opposing traders are trapped. When price retraces at least 50% back into this gap, it creates pressure as these trapped positions look to exit—either through stop-losses or position reversal. This makes the gap most likely to act as a reversal zone.
2. How It Works (The Lifecycle)
The indicator logic follows a strict sequence of events. A signal is generated only if all conditions are met in order:
-- Phase 1: Identification (The Fresh Gap)
The script scans for the classic 3-candle FVG pattern (where the 1st and 3rd candles do not overlap).
Visual: It draws a box (Green for Bullish, Red for Bearish) extending to the right.
The 50% Line: A dashed line is drawn through the center of the gap.
-- Phase 2: Mitigation (The Gray Zone)
This is the critical filter. The indicator waits for a candle to CLOSE past the 50% dashed line.
Once this happens, the gap is considered "Deeply Mitigated."
Visual: The box changes color to Gray. This tells the trader: "Price is deep in the zone, watch for a reaction."
-- Phase 3: The Signal (Rejection)
Once the box is Gray, the script watches for a "Rejection Candle."
Bullish Scenario: Price is deep in the gap (Gray). The script waits for a candle to close higher than it opened (a green candle).
Bearish Scenario: Price is deep in the gap (Gray). The script waits for a candle to close lower than it opened (a red candle).
Visual: A Triangle Label (▲ or ▼) appears, signaling an entry.
-- Phase 4: Invalidation
If the price closes completely past the far edge of the box (the Stop Loss level), the box is deleted immediately.
3. Key Options
These are the most important settings for the user:
-- Min Gap Size (%):
Filters out "noise." It ensures the script ignores tiny, insignificant gaps that are less than X% in height.
-- Max Visible Gaps:
Keeps your chart clean. It limits how many open boxes can be on the screen at once (e.g., only show the last 3 unclosed gaps).
-- Show Signal History Only:
Feature Highlight: When enabled, this hides all the "noise" of open or failed gaps. It only draws the boxes that successfully produced a Rejection Signal in the past.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.