OPEN-SOURCE SCRIPT
Nested FVG Pro

Nested FVG Pro identifies a specific ICT confluence — a 1-minute Fair Value Gap forming inside an active 5-minute Fair Value Gap — and manages a complete multi-contract trade plan around each signal, with journalling that models how automated orders actually fill rather than assuming ideal prices.
HOW IT WORKS
5-minute context. The script aggregates 1-minute bars into rolling 5-minute candles and scans each completed triplet for a displacement gap: a bullish FVG (BISI) exists where the current candle's low sits above the high from two candles back; bearish (SIBI) is the mirror. Gaps must exceed a minimum size in points — set against your stop distance, so an imbalance smaller than meaningful displacement never becomes context. Qualifying zones are drawn and tracked.
Zone lifecycle. A zone is invalidated when price closes through its far side. Invalidated zones are not deleted immediately: they stop extending, dim, and remain on the chart for a configurable number of bars so past signals can be audited, and they are never removed while a trade is open. An active-zone cap per direction prevents stacking — in a sustained trend, zones pointing with the trend are never closed through, so without a cap they accumulate all session and progressively bias signal generation toward chasing the move.
Inversion mode (IFVG). A gap that price has closed through has failed. ICT treats the violated gap as flipped: a bullish FVG closed below becomes resistance, a bearish FVG closed above becomes support. In IFVG mode the invalidation event flips the zone's direction instead of retiring it, and signals are then taken as price returns into the zone from the other side. Inverted zones are colour-coded distinctly, expire on a configurable age, and retire permanently if closed through a second time. Signal Source selects virgin gaps, inverted gaps, or both.
1-minute trigger. On each confirmed 1-minute bar the script tests for a fresh 1-minute FVG using the same three-candle definition and its own minimum size. A signal fires only where that gap sits inside an eligible 5-minute zone of matching direction, within a proximity tolerance in points around the zone boundaries. The premise: a small-timeframe imbalance printing inside a larger unmitigated imbalance marks continuation pressure in the direction of the higher-timeframe displacement.
Signal gating. Cooldown between signals; a hardcoded one-trade-at-a-time block; an exchange-session filter; six independently configurable time windows with editable start and end times in a selectable timezone; and a daily loss limit in dollars that blocks new signals once reached. The daily reset and zone purge are driven by a change of CME trade date rather than a session-transition test, so they behave correctly regardless of whether bars print during the session gap.
Trade management. Each signal is managed as a ladder measured in points from the entry: a stop, a partial exit that optionally moves the stop to break-even, a main target, an extended target, and an optional fourth-contract runner target. All distances and per-level contract counts are inputs. A per-trade dollar maximum-loss exit closes the position on a confirmed bar if unrealised loss breaches the limit.
Optional entry laddering. Position size can be split across up to three legs — the signal bar's close, consequent encroachment (the 50% level of the 1-minute gap), and the gap's far edge — all sharing one structural stop, so each deeper leg risks fewer points than the one before. Fills are position-weighted and exit quantities are capped to what actually filled, so a trade that displaces immediately never sends exits for contracts it never bought. The trade-off is explicit: setups that run straight to target fill the smallest size while setups that retrace fill the largest.
Execution-modelled journalling — what makes this different. Most signal trackers book trades at exact level prices. In live automation, alerts fire once per bar close and fill as market orders, so real fills land at the trigger bar's close rather than at the level touched intrabar. This script separates plan levels, which drive the triggers, from booked fills, which drive the accounting: with fill booking enabled, every entry and exit in the Trade Tracker, Hourly and Weekly tables is recorded at the trigger bar's close plus a configurable per-fill slippage, and round-turn commissions are netted from every result. Levels can be anchored to the entry fill rather than the gap boundary, so a 20-point stop is 20 points from the price paid. Break-even moves to the position's weighted average fill, matching what a broker-side breakeven order does. The result is a journal that reconciles with a broker statement instead of an idealised one.
A/B variant lab. A read-only shadow journal replays every signal a second time under a different partial distance and break-even rule, reporting both policies side by side with the difference between them. It places no orders and never touches the live journal — it answers whether an exit-policy change would have helped on your own history rather than a hypothetical one.
MODES
Runner off: 3-contract exit ladder, flat at the extended target. Runner on: a 4th contract rides to the runner target.
Entry ladder off: one full-size entry. On: up to three scale-in legs sharing one stop.
Signal Source: FVG, IFVG, or Both.
A/B lab off by default.
AUTOMATION (OPTIONAL)
The script emits complete JSON webhook payloads for every event — entry with quantity, order type and an optional attached stop so a real protective order rests at the broker; partial with an optional broker-side breakeven action; break-even scratch; each target; stop; and emergency exit — with quantities computed from the position-sizing inputs. One alert with the condition "Any alert() function call" drives all of it. Manual traders can ignore this entirely and trade the on-chart levels.
HOW TO USE
Apply to a 1-minute chart — the script builds its own 5-minute context, and other chart timeframes will not behave correctly. Set your ladder distances and dollar-per-point for the instrument, choose your windows and timezone, set the minimum gap sizes and proximity in points relative to your stop, and set the daily and per-trade loss limits. Signals print as triangles with the full R/R ladder drawn to the right; the Trade Tracker logs every signal's outcome net of modelled costs.
LIMITATIONS & NOTES
Outcome detection is evaluated on confirmed bars; live automated fills are bar-close market orders, which is precisely what the execution-modelled tables account for.
The analytics model execution. A broker statement remains the ground truth.
All distances are in points and are calibrated per instrument. Moving between instruments of different volatility requires rescaling every point input.
Entry laddering requires add-to-position support in your webhook platform.
This is a technical analysis and automation tool, not financial advice. Past behaviour of any configuration does not guarantee future results. Test on simulated accounts before risking capital.
The source is open — read it, fork it, adapt it. If you change the detection or the accounting, the tables will tell you what the change did.
HOW IT WORKS
5-minute context. The script aggregates 1-minute bars into rolling 5-minute candles and scans each completed triplet for a displacement gap: a bullish FVG (BISI) exists where the current candle's low sits above the high from two candles back; bearish (SIBI) is the mirror. Gaps must exceed a minimum size in points — set against your stop distance, so an imbalance smaller than meaningful displacement never becomes context. Qualifying zones are drawn and tracked.
Zone lifecycle. A zone is invalidated when price closes through its far side. Invalidated zones are not deleted immediately: they stop extending, dim, and remain on the chart for a configurable number of bars so past signals can be audited, and they are never removed while a trade is open. An active-zone cap per direction prevents stacking — in a sustained trend, zones pointing with the trend are never closed through, so without a cap they accumulate all session and progressively bias signal generation toward chasing the move.
Inversion mode (IFVG). A gap that price has closed through has failed. ICT treats the violated gap as flipped: a bullish FVG closed below becomes resistance, a bearish FVG closed above becomes support. In IFVG mode the invalidation event flips the zone's direction instead of retiring it, and signals are then taken as price returns into the zone from the other side. Inverted zones are colour-coded distinctly, expire on a configurable age, and retire permanently if closed through a second time. Signal Source selects virgin gaps, inverted gaps, or both.
1-minute trigger. On each confirmed 1-minute bar the script tests for a fresh 1-minute FVG using the same three-candle definition and its own minimum size. A signal fires only where that gap sits inside an eligible 5-minute zone of matching direction, within a proximity tolerance in points around the zone boundaries. The premise: a small-timeframe imbalance printing inside a larger unmitigated imbalance marks continuation pressure in the direction of the higher-timeframe displacement.
Signal gating. Cooldown between signals; a hardcoded one-trade-at-a-time block; an exchange-session filter; six independently configurable time windows with editable start and end times in a selectable timezone; and a daily loss limit in dollars that blocks new signals once reached. The daily reset and zone purge are driven by a change of CME trade date rather than a session-transition test, so they behave correctly regardless of whether bars print during the session gap.
Trade management. Each signal is managed as a ladder measured in points from the entry: a stop, a partial exit that optionally moves the stop to break-even, a main target, an extended target, and an optional fourth-contract runner target. All distances and per-level contract counts are inputs. A per-trade dollar maximum-loss exit closes the position on a confirmed bar if unrealised loss breaches the limit.
Optional entry laddering. Position size can be split across up to three legs — the signal bar's close, consequent encroachment (the 50% level of the 1-minute gap), and the gap's far edge — all sharing one structural stop, so each deeper leg risks fewer points than the one before. Fills are position-weighted and exit quantities are capped to what actually filled, so a trade that displaces immediately never sends exits for contracts it never bought. The trade-off is explicit: setups that run straight to target fill the smallest size while setups that retrace fill the largest.
Execution-modelled journalling — what makes this different. Most signal trackers book trades at exact level prices. In live automation, alerts fire once per bar close and fill as market orders, so real fills land at the trigger bar's close rather than at the level touched intrabar. This script separates plan levels, which drive the triggers, from booked fills, which drive the accounting: with fill booking enabled, every entry and exit in the Trade Tracker, Hourly and Weekly tables is recorded at the trigger bar's close plus a configurable per-fill slippage, and round-turn commissions are netted from every result. Levels can be anchored to the entry fill rather than the gap boundary, so a 20-point stop is 20 points from the price paid. Break-even moves to the position's weighted average fill, matching what a broker-side breakeven order does. The result is a journal that reconciles with a broker statement instead of an idealised one.
A/B variant lab. A read-only shadow journal replays every signal a second time under a different partial distance and break-even rule, reporting both policies side by side with the difference between them. It places no orders and never touches the live journal — it answers whether an exit-policy change would have helped on your own history rather than a hypothetical one.
MODES
Runner off: 3-contract exit ladder, flat at the extended target. Runner on: a 4th contract rides to the runner target.
Entry ladder off: one full-size entry. On: up to three scale-in legs sharing one stop.
Signal Source: FVG, IFVG, or Both.
A/B lab off by default.
AUTOMATION (OPTIONAL)
The script emits complete JSON webhook payloads for every event — entry with quantity, order type and an optional attached stop so a real protective order rests at the broker; partial with an optional broker-side breakeven action; break-even scratch; each target; stop; and emergency exit — with quantities computed from the position-sizing inputs. One alert with the condition "Any alert() function call" drives all of it. Manual traders can ignore this entirely and trade the on-chart levels.
HOW TO USE
Apply to a 1-minute chart — the script builds its own 5-minute context, and other chart timeframes will not behave correctly. Set your ladder distances and dollar-per-point for the instrument, choose your windows and timezone, set the minimum gap sizes and proximity in points relative to your stop, and set the daily and per-trade loss limits. Signals print as triangles with the full R/R ladder drawn to the right; the Trade Tracker logs every signal's outcome net of modelled costs.
LIMITATIONS & NOTES
Outcome detection is evaluated on confirmed bars; live automated fills are bar-close market orders, which is precisely what the execution-modelled tables account for.
The analytics model execution. A broker statement remains the ground truth.
All distances are in points and are calibrated per instrument. Moving between instruments of different volatility requires rescaling every point input.
Entry laddering requires add-to-position support in your webhook platform.
This is a technical analysis and automation tool, not financial advice. Past behaviour of any configuration does not guarantee future results. Test on simulated accounts before risking capital.
The source is open — read it, fork it, adapt it. If you change the detection or the accounting, the tables will tell you what the change did.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.