OPEN-SOURCE SCRIPT
Fair Value Gap Indicator with Fill Tracking and HTF Gaps

🔵 OVERVIEW
🔵 HOW IT WORKS
🔵 HOW TO USE
🔵 SETTINGS
🔵 ALERTS
🔵 NOTES
Fair Value Gap Indicator with Fill Tracking and HTF Gaps [Viprasol] is an indicator that draws only the fair value gaps (FVG) created by real displacement, tracks how much of each gap has been filled in real time, and keeps statistics on how gaps get revisited and mitigated. It cuts out the clutter of plotting every three-candle gap, and shows how FVGs actually behave on your market instead of leaving you to guess.
🔵 HOW IT WORKS
The indicator detects qualified gaps, follows each one until it is mitigated or expires, and records the outcome:
1 — Gap Detection
- Three-Candle Imbalance: A bullish FVG forms when the low of the current candle is above the high of the candle two bars back, with a bullish middle candle. Bearish is the mirror. The gap is the untraded price area between candle 1 and candle 3.
- Size Filter: The gap height must be at least Minimum gap size × ATR.
- Displacement Filter: The middle candle body must be at least Displacement × ATR, so only gaps created by a decisive move are kept.
2 — Fill Tracking
- Deepest Fill: For every open gap the indicator records the deepest price that traded back into it.
- Live Fill %: The distance traded into the gap divided by the gap height, printed on the box.
- 50% Line: An optional dotted line at the middle of the gap (consequent encroachment).
3 — Mitigation
- Full fill: The whole gap has been traded through.
- 50% fill: Price reached consequent encroachment.
- Close through: A candle closed beyond the far edge.
- Expiry: Gaps left unfilled for longer than the bar limit are removed. Mitigated gaps can stay on the chart, faded.
4 — Higher-Timeframe Gaps
- Completed Candles Only: HTF gaps use the last three completed candles of the Higher timeframe (no lookahead), so a daily fair value gap appears once the daily candle that completes it has closed.
🔵 HOW TO USE
Beyond marking imbalances, you can use the indicator in several ways:
- Support and Resistance Zones: Watch fresh bullish FVGs as possible support on pullbacks, and bearish FVGs as possible resistance.
- Fair Value Gap Entries: Many traders watch the first return into a gap and its 50% line. The "% filled" label shows how deep price has already gone.
- Multi-Timeframe Map: Turn on HTF gaps (for example 4H on a 15m chart) to see which gaps matter on the bigger picture.
- Match Your Definition: Pick the mitigation rule that fits how you trade gaps. "Close through" keeps gaps longer than "50% fill".
- Read the Statistics: If most gaps on your symbol get fully filled within a few bars, trading away from them is less reliable there.
🔵 SETTINGS
- Detection: Minimum gap size, Displacement, ATR length, Gap is mitigated on, Max active gaps per side, Expire unfilled gaps after.
- Higher-timeframe gaps: on/off and Higher timeframe.
- Display: bullish/bearish toggles, colours, 50% line, live fill %, keep mitigated gaps, statistics table and position.
🔵 ALERTS
- New bullish / bearish FVG: a qualified gap has just formed.
- Price returned to bullish / bearish FVG: the first touch back into a gap.
- FVG mitigated: a gap met your mitigation rule.
All alerts fire once per bar close.
🔵 NOTES
Why this implementation is unique:
- Displacement and ATR-size filters remove most of the noise that plain FVG scripts plot.
- A live fill percentage on every open gap, not just an on/off state.
- Three mitigation definitions in one tool.
- Non-repainting higher-timeframe gaps built only from completed candles.
- A revisit and mitigation record, so you can judge FVG behaviour on your own market.
Limitations:
- A gap is confirmed only when its third candle closes, so it appears one bar after the displacement candle.
- Higher-timeframe gaps are drawn from the moment their HTF candle closes, not back in time.
- The statistics count chart-timeframe gaps only. They describe this chart's past and do not predict future fills.
- The maximum number of active gaps per side caps the boxes, and the oldest gaps are removed first.
This script is for education and analysis. It does not give financial advice.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
Viprasol We solve Infinity
Whatsapp +919633652112
Lets do it Together All Automation Solutions Available
Whatsapp +919633652112
Lets do it Together All Automation Solutions Available
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
Viprasol We solve Infinity
Whatsapp +919633652112
Lets do it Together All Automation Solutions Available
Whatsapp +919633652112
Lets do it Together All Automation Solutions Available
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.