OPEN-SOURCE SCRIPT

FVG Toolkit [Smart Money]

534
A Fair Value Gap is a 3-candle imbalance: a candle runs hard and leaves a void that the candles around it never fully cover. But the version most tools draw is only one of three the price-action crowd actually watches. There is the visible Classic gap, the Implied gap hidden inside a single oversized candle, and the Inversion gap that appears when a broken FVG flips and starts acting as support or resistance. Tracking these one type at a time means three layers of clutter and a lot of switching back and forth. FVG Toolkit detects all three on one overlay and merges their overlap into a single confluence zone, so the chart shows structure instead of noise.

HOW IT WORKS

Three FVG families, each independently toggleable, are detected on confirmed bars only:

- **Classic FVG** — the standard visible 3-candle imbalance: the wicks of candle 1 and candle 3 do not overlap, leaving an open gap (bullish `low[0] > high[2]`, bearish `high[0] < low[2]`).
- **Implied FVG** — a hidden imbalance carried by a single large candle whose outer wicks overlap. The gap is measured between the Consequent Encroachment (the 50% level) of those outer wicks. This is ElisTools' operational definition of an Implied FVG; the ICT community uses several variants, so this one is stated openly rather than presented as the only version.
- **Inversion FVG** — a Classic FVG whose boundary gets broken flips polarity and becomes a support/resistance zone: a bearish FVG broken upward becomes a bullish IFVG, and a bullish FVG broken downward becomes a bearish IFVG.

Each gap is then managed through an honest lifecycle:

- **Classic / Implied** are shown as a full zone. When price reaches the far edge the gap is violated and removed (or kept, your choice). There is no partial-fill shading — a zone is either present or gone.
- **Inversion** runs on two independent axes. Validation is the flip itself (the Classic boundary is broken, by Wick or Body) and births the IFVG; Invalidation is the opposite boundary being broken (by Wick or Body) and removes it. Because the two axes are separate, you can flip strictly and invalidate loosely, or any other mix.
- **Cluster** — when a fresh same-direction Classic FVG forms over an existing IFVG (a common displacement byproduct), the two are merged into one reinforced union zone spanning their full combined extent. This is confluence, not a BPR. Cluster priority is direction-aware: a cluster takes precedence only over overlapping standalone zones of the same direction — an opposite-side gap is never touched.

A `Min gap size (ATR x)` filter skips trivial micro-gaps, and Inversion inherits it (a filtered-out Classic can never flip). Every zone can carry an optional 50% (CE) line and label, with its own per-type and per-side colors.

1) A confirmed bar is scanned for Classic, Implied, and Inversion conditions (each only if enabled)
2) Surviving gaps are drawn as full zones; a same-direction Classic over an IFVG is merged into a cluster
3) Price reaching a far edge violates Classic/Implied; a broken boundary validates or invalidates an Inversion

HOW TO READ

- A Classic zone is a visible 3-candle imbalance; an Implied zone marks the void inside one oversized candle; an Inversion zone is a former gap now flipped to the other side.
- A cluster (its own color) is a same-direction Classic and IFVG stacked together — overlap collapsed into one zone rather than two competing ones.
- The optional 50% line is the Consequent Encroachment, the midpoint many price-action traders watch inside a gap.
- "Bullish" and "Bearish" describe the direction of the pattern, not a buy or sell instruction. Marking any of these zones says nothing about whether price will fill it, hold there, or reverse. The tool maps the structure; the read is yours.

INPUTS

- Max zones / Extend right — how many zones to keep on chart, and how far to project them.
- Min gap size (ATR x) — skip gaps smaller than this multiple of ATR(14); 0 turns the filter off. Inversion inherits it.
- Show Classic / Show Implied / Show Inversion — enable each family independently; each has its own color(s).
- Middle body >= ATR x (Implied) — how large the single middle candle must be to qualify as an Implied gap.
- Validation (flip) — how a Classic flips into an IFVG: Body (a body closes beyond the boundary, ICT-strict, default) or Wick (a wick beyond it, looser).
- Invalidation — how a formed IFVG is removed: Wick (a wick beyond the opposite boundary, default) or Body (a body close beyond it, ICT-strict).
- Remove on violation / Violation by — drop a Classic/Implied zone when its far edge is reached; Wick (intrabar) or Close (bar close).
- Merge same-dir overlap — fuse a same-direction Classic + IFVG into one cluster zone; with its own cluster color.
- Style — show labels, show 50% (CE) line and its width, zone border and its width.

ALERTS

Two layers, set up separately in the alert dialog.

- Detection (four conditions: New bullish/bearish Classic FVG and New bullish/bearish Implied FVG) are picked from the condition dropdown and fire on closed bars — use "Once Per Bar Close."
- Lifecycle (FVG inverted, Inversion FVG invalidated, FVG mitigated) fire through alert() function calls — create them with "Any alert() function call." Use "Once Per Bar" when the matching axis is set to Wick, and "Once Per Bar Close" when it is set to Body or Close.

NOTES & LIMITS

This is an observation tool, not a forecast. Marking a Classic, Implied, or Inversion FVG says nothing about whether the gap fills, holds, or reverses — it only shows where the structure sits. The Implied FVG uses ElisTools' operational definition (a large middle body, overlapping outer wicks, and the gap measured between their 50% levels); the ICT community uses several variants, so this one is stated openly rather than claimed as the single canon. The cluster is a confluence union of a same-direction Classic and IFVG, not a Balanced Price Range, and it never removes an opposite-side gap. No repaint, no lookahead: zones are created on confirmed (closed) bars only and their levels never move. Wick-based lifecycle rules update intrabar but stay exact, because a bar's high and low are running extremes that are never revised; Body and Close rules act only on bar close. No profit, win-rate, or guarantee claim. Open-source under CC BY-NC-SA 4.0 — non-commercial use, attribution to ElisTools required for reuse or derivatives. TradingView (Pine v6) only.

免责声明

这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。