OPEN-SOURCE SCRIPT
Aggiornato GProf - FVG Alerts

GProf - FVG Alerts
═══════════════════════════════════════════
OVERVIEW
This indicator detects standard 3-candle Fair Value Gaps (FVGs), draws every gap as a live zone, and fires an alert only when a gap is both large enough to matter and sits in an area with room to the left. It is built to surface displacement worth trading and stay silent on the rest.
Everything confirms on the close of the third candle — nothing is drawn or alerted intrabar, so a gap that appears mid-candle and vanishes before the close never produces a false alert.
───────────────────────────────────────────
DETECTION
• Bullish FVG — the current candle's low is above the high from two bars ago. The zone spans from that prior high (bottom) to the current low (top).
• Bearish FVG — the current candle's high is below the low from two bars ago. The zone spans from the current high (bottom) to that prior low (top).
───────────────────────────────────────────
THE ALERT FILTER — SIZE AND ROOM
Every FVG is drawn. An alert fires only when BOTH conditions are met:
1. SIZE — the gap is at least a set percentage of the daily ATR (default 2%), with a tick floor. Measuring against ATR rather than a fixed point value makes the threshold portable: it means the same thing on a fast index future and a slow one, and it adapts as volatility changes. A fixed-points mode is also available.
2. ROOM TO THE LEFT — the origin of the impulse that created the gap must be in clean territory: the anchor level (the extreme of the move) has few prior candle bodies overlapping it across a lookback window (defaults: 3 bodies over 20 bars). A gap that forms in the middle of prior congestion is drawn but does not alert.
Gaps are shown in three tiers so the chart teaches you over time:
• Full color — qualified on size AND room: these alert.
• Muted gray — big enough, but the anchor lacked room to the left: drawn, silent.
• Faint — below the size threshold: drawn, silent.
Watching which large gaps had room and which did not, and how price treats each, tells you where your own thresholds belong.
───────────────────────────────────────────
ZONE MANAGEMENT
• Zones extend right until fully filled: a bullish gap is removed when price trades down through the bottom of the zone, a bearish gap when price trades up through the top.
• Partial fills leave the zone at its original size — the original boundaries remain the reference, not the shrinking remainder.
• A configurable cap limits how many zones stay on the chart; oldest are removed first.
───────────────────────────────────────────
ALERTS — HOW TO SET UP
1. Add the indicator to your chart.
2. Open the Alert dialog and set the Condition to this indicator.
3. Select "Any alert() function call".
4. Set Expiration to Open-ended and choose your notification methods.
One alert covers everything. The Alert Direction input controls what fires: Both, Bullish Only, Bearish Only, or Off. Alert messages include the symbol, timeframe, direction, gap size in points and as a percentage of ATR, whether room-to-the-left is clean, and the exact zone boundaries.
Note: TradingView alerts snapshot the indicator's settings when created. If you change the size threshold or other settings later, edit and re-save (or recreate) the alert for the new values to take effect.
───────────────────────────────────────────
HOW TO USE IT
FVGs mark displacement — areas price moved through so fast that an imbalance was left behind. Many traders study them as zones of interest for retracement entries, targets, or invalidation. This indicator identifies and sizes the gaps, flags the significant ones that also have room to the left, and otherwise stays out of the way. Combine it with your own market structure analysis, session context, and risk management.
This indicator identifies a chart pattern. It does not generate buy/sell recommendations, does not place trades, and does not replace your own analysis and risk management.
───────────────────────────────────────────
TECHNICAL NOTES
• Non-repainting: detection, drawing, and alerts occur on confirmed bar closes only.
• Works on any symbol and timeframe. Size thresholds are a percentage of daily ATR with tick floors, so they travel across instruments and volatility regimes; a fixed-points mode is available.
• Colors, transparency, borders, size threshold, and the room-to-the-left lookback are fully configurable.
───────────────────────────────────────────
DISCLAIMER
This script is for informational and educational purposes only. It does not constitute financial, investment, or trading advice. Fair Value Gaps are a chart pattern, not a guarantee of future price behavior. All trading decisions made using this tool are solely the responsibility of the user.
═══════════════════════════════════════════
OVERVIEW
This indicator detects standard 3-candle Fair Value Gaps (FVGs), draws every gap as a live zone, and fires an alert only when a gap is both large enough to matter and sits in an area with room to the left. It is built to surface displacement worth trading and stay silent on the rest.
Everything confirms on the close of the third candle — nothing is drawn or alerted intrabar, so a gap that appears mid-candle and vanishes before the close never produces a false alert.
───────────────────────────────────────────
DETECTION
• Bullish FVG — the current candle's low is above the high from two bars ago. The zone spans from that prior high (bottom) to the current low (top).
• Bearish FVG — the current candle's high is below the low from two bars ago. The zone spans from the current high (bottom) to that prior low (top).
───────────────────────────────────────────
THE ALERT FILTER — SIZE AND ROOM
Every FVG is drawn. An alert fires only when BOTH conditions are met:
1. SIZE — the gap is at least a set percentage of the daily ATR (default 2%), with a tick floor. Measuring against ATR rather than a fixed point value makes the threshold portable: it means the same thing on a fast index future and a slow one, and it adapts as volatility changes. A fixed-points mode is also available.
2. ROOM TO THE LEFT — the origin of the impulse that created the gap must be in clean territory: the anchor level (the extreme of the move) has few prior candle bodies overlapping it across a lookback window (defaults: 3 bodies over 20 bars). A gap that forms in the middle of prior congestion is drawn but does not alert.
Gaps are shown in three tiers so the chart teaches you over time:
• Full color — qualified on size AND room: these alert.
• Muted gray — big enough, but the anchor lacked room to the left: drawn, silent.
• Faint — below the size threshold: drawn, silent.
Watching which large gaps had room and which did not, and how price treats each, tells you where your own thresholds belong.
───────────────────────────────────────────
ZONE MANAGEMENT
• Zones extend right until fully filled: a bullish gap is removed when price trades down through the bottom of the zone, a bearish gap when price trades up through the top.
• Partial fills leave the zone at its original size — the original boundaries remain the reference, not the shrinking remainder.
• A configurable cap limits how many zones stay on the chart; oldest are removed first.
───────────────────────────────────────────
ALERTS — HOW TO SET UP
1. Add the indicator to your chart.
2. Open the Alert dialog and set the Condition to this indicator.
3. Select "Any alert() function call".
4. Set Expiration to Open-ended and choose your notification methods.
One alert covers everything. The Alert Direction input controls what fires: Both, Bullish Only, Bearish Only, or Off. Alert messages include the symbol, timeframe, direction, gap size in points and as a percentage of ATR, whether room-to-the-left is clean, and the exact zone boundaries.
Note: TradingView alerts snapshot the indicator's settings when created. If you change the size threshold or other settings later, edit and re-save (or recreate) the alert for the new values to take effect.
───────────────────────────────────────────
HOW TO USE IT
FVGs mark displacement — areas price moved through so fast that an imbalance was left behind. Many traders study them as zones of interest for retracement entries, targets, or invalidation. This indicator identifies and sizes the gaps, flags the significant ones that also have room to the left, and otherwise stays out of the way. Combine it with your own market structure analysis, session context, and risk management.
This indicator identifies a chart pattern. It does not generate buy/sell recommendations, does not place trades, and does not replace your own analysis and risk management.
───────────────────────────────────────────
TECHNICAL NOTES
• Non-repainting: detection, drawing, and alerts occur on confirmed bar closes only.
• Works on any symbol and timeframe. Size thresholds are a percentage of daily ATR with tick floors, so they travel across instruments and volatility regimes; a fixed-points mode is available.
• Colors, transparency, borders, size threshold, and the room-to-the-left lookback are fully configurable.
───────────────────────────────────────────
DISCLAIMER
This script is for informational and educational purposes only. It does not constitute financial, investment, or trading advice. Fair Value Gaps are a chart pattern, not a guarantee of future price behavior. All trading decisions made using this tool are solely the responsibility of the user.
Note di rilascio
// v1.4 — IMPULSE-ORIGIN anchor. v1.3's fixed N-bar window still// anchors MID-impulse on long moves: by the time the gap
// confirms, the window no longer reaches the start of the
// leg, and RTL passes because price was travelling THROUGH
// that level rather than resting at it (MES Jul 27 — a
// sell-off from 7524 anchored near 7516 and passed, with
// an hour of congestion sitting above the true origin).
// The anchor now WALKS BACK to the swing where the impulse
// began: keep extending while the move makes new extremes,
// stop once Swing Pivot bars in a row fail to extend it.
// Self-scaling to short and long impulses. RTL is counted
// in the bars BEFORE that origin.
// Also: SESSION-BREAK EXCLUSION — a 3-candle window that
// spans the daily halt is a calendar artifact, not
// displacement (no auction occurred during the break, so
// there is no imbalance to fill). Those gaps no longer
// register at all — covers the Sunday 18:00 ET open and
// every nightly 18:00 open.
Note di rilascio
v1.6 — CHAIN AWARENESS. The tool now answers "who just took// control" rather than grading every gap in isolation.
// IMPULSE (chain start): a qualified FVG WITH room to the
// left — a new move beginning in clean air. Full colour,
// heavy border, ALERTS. This is the only thing that
// alerts.
// reload N: a qualified FVG in the SAME direction while
// that chain is still live. It has no room by definition,
// because it prints inside a move already under way — so
// it is labelled and numbered, not treated as a failure.
// Drawn, never alerted. Numbering continues past three:
// the trader and the algo stop taking them, but they stay
// identified.
// A chain ends when an opposing IMPULSE prints (control
// flips) or price CLOSES beyond the chain origin (the
// fib-1 anchor of the leg that started it).
// Rationale: RTL was rejecting exactly the continuation
// signals the trader wanted to see. RTL is not a quality
// filter — it is the test that identifies a chain START.
// Inside a live chain, no room is the expected state.
// CHAIN MEMBERSHIP VETOES THE ALERT: a qualified gap in
// the same direction as a LIVE chain never alerts, even
// if it happens to pass RTL. Mid-move gaps often pass on
// a technicality — their origin is a fresh local low with
// little beneath it — but they are not news when you are
// already in that chain. They stay drawn and visible.
// Text labels removed. The distinction is carried by
// COLOUR: alerting gaps are bright and saturated, silent
// gaps deliberately muted, sub-threshold barely there.
// All three tiers are configurable in Display. Colour is
// keyed to whether the gap will ACTUALLY ALERT — not
// merely to whether RTL passed — so what you see on the
// chart is exactly what your phone would have told you.
//
Note di rilascio
// v1.9.1 — TWO INPUT DEFAULTS. NO LOGIC CHANGE.//
// (1) MAX OVERLAPPING BODIES -> 0.
//
// Room to the left means NO bodies in the way. rtlMax had
// defaulted to 3 since v1.2, carried in unexamined from the GZ
// Developer Spec's F2 "starting value", and never revisited
// through eight releases. It let a gap alert with three bodies
// already sitting at its anchor.
// MGC Aug 28 exposed it: three reload gaps in a waterfall, each
// reading "hits 3 / overlaps 1 (max 3)" -> ALERTS. The single
// body at offset 3 — the candle immediately left of the gap —
// was seen and then waved through. On a fast drop, successive
// anchors fall away faster than the band is wide, so a reload
// never accumulates more than one or two overlaps and the old
// threshold could never catch it.
// MYM Aug 28 at rtlMax = 0 reads correctly end to end: 53,860
// alerts (overlaps 0), 53,840 silent (overlaps 2), 53,531 and
// 53,548 alert (overlaps 0), every other gap silent.
// NOTE this supersedes the earlier reading of the annotated MYM
// chart, where 53,840 was taken to be a correct alert. It is
// not: two bodies sit at its level. The v1.9 header cites it as
// evidence that a live chain must not suppress a gap — that
// conclusion still holds (53,548 alerts inside a live chain
// with a clean anchor), but 53,840 is no longer the example.
//
// (2) ANCHOR BAND -> 1.5 (from 3.0).
// The band was inflating counts everywhere. MNQ Aug 28, a clean
// double top, bearish gap anchored 29,785.75: label read
// "hits 3,7,8,9 / overlaps 4" when only TWO bodies sit in a
// direct line left of the wick. At 3% the band was +/-15.38 on a
// 505.75 ATR, reaching far below the high and counting bodies
// that were never at the level.
// Bisected live: the gap prints at 1.5 and below, stays silent
// at 2.0. So one body sat between 7.6 and 10.1 points under the
// anchor and was casting the deciding vote.
// The band still exists for the reason it was introduced in
// v1.5 (an extreme is a zone; the exact high is made by a wick,
// so an exact-tick test can read 0 with congestion stacked just
// beneath). 1.5 keeps that and drops the over-reach.
//
// UNVERIFIED AT THE TIME OF WRITING: 1.5 was bisected on MNQ
// only. It must be checked on MGC (do the waterfall reloads
// stay silent, or does the tighter band drop them to 0 overlaps
// and alert them again?) and on MCL 82.33 (does it fall below
// rtlMax and finally alert?). If MGC regresses, band and rtlMax
// are trading against each other and the next step is design,
// not tuning.
//
// KNOWN COST, to watch: any gap that alerted on 1-3 overlaps
// now goes silent. MCL Aug 28's bearish gap at 83.62 read
// "overlaps 1" and alerted under v1.9; it will now be silent,
// and it has not been validated either way.
// MCL 82.33 (overlaps 4) remains silent and remains the one
// documented false negative — a setup that made target. It is
// unaffected by this change; it needs the window or the band
// revisited, not the threshold.
// v1.9.2 — MAX OVERLAPPING BODIES BACK TO 3. Input default only.
// v1.9.1's 0 was correct on continuation and wrong on
// reversals: it silenced the MGC waterfall reloads and MYM
// 53,840 as intended, but also silenced MCL Aug 28 bullish
// (4 overlaps at band 1.5) — a setup that filled the 0.5 and
// made +3R. 3 and 0 are both under live test; the setting must
// be recorded alongside any screenshot, since a gap's verdict
// is meaningless without it.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
GProf Trades
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
GProf Trades
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.