OPEN-SOURCE SCRIPT
更新済

FVG Sigma [Smart Money]

554
A Fair Value Gap is a 3-candle imbalance: the middle candle runs hard and leaves a void between candle 1 and candle 3. The problem with marking them is that gaps come in every size — most tools draw every single one, and the chart fills with noise where trivial micro-gaps sit next to the ones that actually mattered. FVG Sigma measures each gap's width and keeps only the statistically unusual ones.

HOW IT WORKS

Every gap's geometric width is fed into a rolling sample pool, with separate pools for bullish and bearish gaps. A new gap is z-scored against its own pool *before* it is added (no look-ahead into its own sample):

`z = (gap width − mean) / standard deviation`

Only gaps with `z >= threshold` (e.g. 2 sigma) are drawn — "unusually large for this symbol on this timeframe." Because a z-score is scale-free (the mean and the standard deviation share the gap's own units), there is no ATR or point normalization to tune; sigma absorbs symbol and timeframe scale on its own. The pool still collects *every* gap, so the baseline stays honest — but only the outliers reach the chart. Until a pool has gathered Min Samples gaps, nothing is drawn (warm-up).

Each surviving gap is then tracked for mitigation. The zone splits into a vivid *fresh* band and a faded *consumed* band at the deepest penetration so far (a high-water mark that never retreats), and an in-zone label reports consumption as a live percentage. When the consumed front reaches the far edge, the gap is fully mitigated and removed (or kept faded, your choice).

1) A confirmed 3-candle gap is measured and z-scored against its side's pool
2) If `z >= threshold`, the zone is drawn; otherwise it is only added to the pool
3) Price penetration splits the zone fresh/consumed and updates the live percentage

HOW TO READ

- A vivid band is the fresh, un-touched portion of a significant gap.
- The faded band behind it is the part price has already traded through.
- The in-zone label is the live consumed percentage (how much of the gap is gone).
- "Significant" means statistically large — an unusual imbalance, not a buy or sell instruction. A large gap is just a large gap; it does not predict fill, reversal, or direction. The tool marks the area; the read is yours.

INPUTS

- Sample Size N — how many recent gap widths each side's pool holds.
- Z-Score Threshold (sigma) — how extreme a gap must be to be drawn. Higher = fewer, stronger gaps.
- Min Samples — warm-up; filtering starts only once the pool has this many gaps.
- Mitigation — Wick (penetration tracked by bar high/low, live but exact) or Close (only confirmed closes count).
- Remove Mitigated / Avoid Overlap — drop fully-consumed zones; skip a new gap that overlaps a same-side one.
- Bullish FVG / Bearish FVG — enable each side independently.
- Show Last Bullish / Bearish — per-side display caps.
- Extend Right / Show Consumed % — projection length; toggle the live label.
- Style — bullish/bearish fills and text colours, fresh and mitigated transparency.

ALERTS

Two separate conditions: New significant Bullish FVG and New significant Bearish FVG. Both fire on closed bars — use "Once Per Bar Close."

NOTES & LIMITS

This is a statistical observation, not a forecast: the filter flags gaps that are unusually large for the current symbol and timeframe, nothing more. It does not say a gap will be filled, hold, or reverse. Scale-free by design — the z-score normalizes symbol and timeframe scale, so there is no ATR or point setting to calibrate. No repaint, no lookahead: gaps are created on confirmed (closed) bars only and their levels never move. Mitigation in Wick mode updates the consumed percentage live but stays exact, because a bar's high/low is a running extreme that is never revised; Close mode updates only on bar close. Open-source under CC BY-NC-SA 4.0 — non-commercial use, attribution to ElisTools required for reuse or derivatives. TradingView (Pine v6) only.
リリースノート
Lifecycle stats — what actually happened to the significant gaps.

The σ filter tells you a gap is unusually large. It doesn't tell you what became of it. This update counts that, on your symbol and timeframe, from the history on your chart.

A new panel (top right) reports, separately for bullish and bearish gaps:

Sample — how many significant gaps have a settled outcome
CE reached — how many touched the midpoint (top+bot)/2
Filled — how many reached the far edge
Unfilled — how many did not, within the window

How a gap settles

Every gap that passes the σ filter is enrolled at birth and followed for H bars (Outcome Window, default 100). If it fully fills inside that window it settles as Filled; if the window runs out first it settles as Unfilled. Either way it is counted once, then dropped — a settled outcome is never revised. That is why the panel header carries the window: the claim is "within 100 bars", not "ever". A gap that fills on bar 105 does not reach back and change a number you already read.

The full-fill definition inherits your Mitigation setting (Wick or Close), so the panel agrees with the zones you see on the chart.

The sample is wider than the chart

Enrolment happens before the display filters. Avoid Overlap and Show Last N control what gets drawn, not what gets counted — otherwise the sample would be biased toward whichever gaps happened to have room on the chart. So Sample can read 137 while ten boxes are visible. That is intended.

Thin samples stay blank

Percentages appear only once the settled sample reaches 20. Below that the cells show a dash. Six out of eight is not a rate worth printing.

Counting

Counters advance on confirmed bars only and move one way. The numbers do not shift intrabar, and a reload reproduces them exactly.

New inputs

Lifecycle Stats (on) — the panel.
Outcome Window (bars) (100) — H, the follow-up window.

No new alerts, no new drawings on the chart.

免責事項

これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。