OPEN-SOURCE SCRIPT
ที่อัปเดต: Ultimate FVG/NWOG By FreedomByCharts

Ultimate FVG/NWOG By FreedomByCharts
A clean, no-bloat FVG and NWOG indicator built around how I actually trade: chart timeframe + three independent higher timeframes + the New Week Opening Gap, all in one global colour scheme with sensible defaults and granular per-source control.
Why this one
Most FVG indicators on TV fall into one of two camps. Either they're stripped down to the bare chart-timeframe pattern with a single fill colour and a hardcoded mitigation rule, or they're bloated with theme presets, IPDA modes, half-finished features and ten settings groups you'll never use. This one is built the other way round: deep where it matters (mitigation logic, NWOG accuracy, display control), and stripped of everything that doesn't earn its place on the chart.
What's actually different:
Four mitigation modes, not one. Wick Filled (full), Body Filled (full), Wick 50%, Body 50%. Pick what matches your model — strict body close beyond the far side, or a partial wick into the midpoint, or anything between.
Independent box and line visibility per source. Box on, lines off. Lines on, box off. Top + bottom only, no middle. Mid line dotted, top and bottom solid. Whatever you want — five sources, each independent.
Mitigated FVGs become iFVGs. When an FVG gets mitigated its label flips from e.g. `1H` to `1H iFVG`, marking the zone as an inverted FVG — the same level can now act in the opposite direction. NWOG labels stay as `NWOG` since the inversion concept doesn't apply.
Mitigated zones can drop their lines automatically. Per-source toggle: keep the grey box for context, lose the line clutter. Active zones stay fully drawn.
Three HTFs at once, plus chart TF, plus NWOG. Run 1H, 4H, 1D simultaneously while the chart-TF FVGs print on whatever you're looking at. Each fully configurable. No request.security guesswork — the HTF tracking is explicit and aligned to the chart bars where each HTF period's high and low actually occurred.
NWOG done properly, including holiday weeks. The NWOG anchors to the close of the last 1H bar before the weekend (Friday on a normal week, Thursday on Easter / Good Friday week) and the open of Sunday's first 1H bar. No stale Friday-only state, no wrong-priced boxes anchored at the wrong bar after holiday closes.
Single global colour scheme. One bullish colour, one bearish colour, one mitigated grey. Applied uniformly across every source for a clean, professional look. NWOG can override its own bull/bear colours if you want it to stand out.
No display caps you have to work around. Set the unfilled count and mitigated count per source to whatever you actually want to see. Old zones get pruned automatically as new ones form.
What it draws
Chart FVGs — current timeframe, both bullish and bearish.
HTF1, HTF2, HTF3 — three configurable higher timeframes (defaults: 1H, 4H, 1D), all rendered on the current chart.
NWOG — the body gap between the close of the last 1H trading bar before the weekend and the open of Sunday's first 1H bar.
For each zone you get an optional coloured box (transparency adjustable), an optional top line, mid line, bot line (each with independent show/hide and Solid/Dashed/Dotted style), and an optional label showing the timeframe (auto-formatted as "1H", "4H", "1D", "NWOG", etc).
When a zone is mitigated, the box recolours to grey, the lines either go grey or hide entirely depending on the per-source toggle, and the label flips to show iFVG status (e.g. `1H` becomes `1H iFVG` — NWOGs keep their `NWOG` label). Mitigated zones stay visible for as many slots as you allow, then get pruned.
Mitigation methods explained
For a bullish FVG (zone below price), the chosen method tests whether price has come back down into the zone:
Wick Filled (full) — bar's low has reached the bottom of the zone. Default.
Body Filled (full) — bar's close has reached the bottom of the zone.
Wick 50% — bar's low has reached the midpoint.
Body 50% — bar's close has reached the midpoint.
Bearish zones (above price) test the opposite direction. Mitigation triggers an alert if you've enabled it for that source.
Alerts
Two alert flags per source: entry (price first touches the zone) and mitigation (price meets the mitigation criterion). Alert text identifies the source timeframe, direction (bull or bear) and the price.
Settings, top to bottom
Appearance — bull / bear / mitigated colours, box transparency, mitigated box transparency, line width, right-edge extension (default 0 = right edge sits at the current bar; raise it to extend further right), label text colour.
Mitigation — single global mitigation method dropdown.
Chart — enable, box / line visibility, line styles, unfilled and mitigated counts, mitigated-lines toggle, label settings, alerts.
HTF 1, HTF 2, HTF 3 — same controls as Chart plus a timeframe input.
NWOG — same controls as the others, plus optional NWOG-specific bull/bear colour overrides.
Notes on usage
For NWOG live detection use a 1H or smaller intraday chart. On 4H+ charts the bar boundaries don't land on the 18:00 NY moment cleanly so new NWOGs won't form.
HTF FVGs appear on the chart at the bar where their HTF period closed, anchored back to the chart bars where the relevant HTF candle highs and lows occurred — this gives a clean "stepped" visual at the zone's left edge that shows how it formed.
The right edge of every zone tracks the current bar in real time. Set "Extend right beyond current bar" higher if you prefer a fixed runway.
TradingView caps total drawn objects at 500 lines / 500 boxes / 500 labels. With three lines per zone enabled across many sources at high display caps, you can hit those limits — drop the mid line first (it's off by default for that reason) and you double your headroom.
Built specifically for the way I trade GC futures on the 1H. Sharing because I haven't seen another FVG indicator that handles all three of these together: holiday-week NWOGs, four mitigation modes, and independent box/line control per source. Feedback welcome.
A clean, no-bloat FVG and NWOG indicator built around how I actually trade: chart timeframe + three independent higher timeframes + the New Week Opening Gap, all in one global colour scheme with sensible defaults and granular per-source control.
Why this one
Most FVG indicators on TV fall into one of two camps. Either they're stripped down to the bare chart-timeframe pattern with a single fill colour and a hardcoded mitigation rule, or they're bloated with theme presets, IPDA modes, half-finished features and ten settings groups you'll never use. This one is built the other way round: deep where it matters (mitigation logic, NWOG accuracy, display control), and stripped of everything that doesn't earn its place on the chart.
What's actually different:
Four mitigation modes, not one. Wick Filled (full), Body Filled (full), Wick 50%, Body 50%. Pick what matches your model — strict body close beyond the far side, or a partial wick into the midpoint, or anything between.
Independent box and line visibility per source. Box on, lines off. Lines on, box off. Top + bottom only, no middle. Mid line dotted, top and bottom solid. Whatever you want — five sources, each independent.
Mitigated FVGs become iFVGs. When an FVG gets mitigated its label flips from e.g. `1H` to `1H iFVG`, marking the zone as an inverted FVG — the same level can now act in the opposite direction. NWOG labels stay as `NWOG` since the inversion concept doesn't apply.
Mitigated zones can drop their lines automatically. Per-source toggle: keep the grey box for context, lose the line clutter. Active zones stay fully drawn.
Three HTFs at once, plus chart TF, plus NWOG. Run 1H, 4H, 1D simultaneously while the chart-TF FVGs print on whatever you're looking at. Each fully configurable. No request.security guesswork — the HTF tracking is explicit and aligned to the chart bars where each HTF period's high and low actually occurred.
NWOG done properly, including holiday weeks. The NWOG anchors to the close of the last 1H bar before the weekend (Friday on a normal week, Thursday on Easter / Good Friday week) and the open of Sunday's first 1H bar. No stale Friday-only state, no wrong-priced boxes anchored at the wrong bar after holiday closes.
Single global colour scheme. One bullish colour, one bearish colour, one mitigated grey. Applied uniformly across every source for a clean, professional look. NWOG can override its own bull/bear colours if you want it to stand out.
No display caps you have to work around. Set the unfilled count and mitigated count per source to whatever you actually want to see. Old zones get pruned automatically as new ones form.
What it draws
Chart FVGs — current timeframe, both bullish and bearish.
HTF1, HTF2, HTF3 — three configurable higher timeframes (defaults: 1H, 4H, 1D), all rendered on the current chart.
NWOG — the body gap between the close of the last 1H trading bar before the weekend and the open of Sunday's first 1H bar.
For each zone you get an optional coloured box (transparency adjustable), an optional top line, mid line, bot line (each with independent show/hide and Solid/Dashed/Dotted style), and an optional label showing the timeframe (auto-formatted as "1H", "4H", "1D", "NWOG", etc).
When a zone is mitigated, the box recolours to grey, the lines either go grey or hide entirely depending on the per-source toggle, and the label flips to show iFVG status (e.g. `1H` becomes `1H iFVG` — NWOGs keep their `NWOG` label). Mitigated zones stay visible for as many slots as you allow, then get pruned.
Mitigation methods explained
For a bullish FVG (zone below price), the chosen method tests whether price has come back down into the zone:
Wick Filled (full) — bar's low has reached the bottom of the zone. Default.
Body Filled (full) — bar's close has reached the bottom of the zone.
Wick 50% — bar's low has reached the midpoint.
Body 50% — bar's close has reached the midpoint.
Bearish zones (above price) test the opposite direction. Mitigation triggers an alert if you've enabled it for that source.
Alerts
Two alert flags per source: entry (price first touches the zone) and mitigation (price meets the mitigation criterion). Alert text identifies the source timeframe, direction (bull or bear) and the price.
Settings, top to bottom
Appearance — bull / bear / mitigated colours, box transparency, mitigated box transparency, line width, right-edge extension (default 0 = right edge sits at the current bar; raise it to extend further right), label text colour.
Mitigation — single global mitigation method dropdown.
Chart — enable, box / line visibility, line styles, unfilled and mitigated counts, mitigated-lines toggle, label settings, alerts.
HTF 1, HTF 2, HTF 3 — same controls as Chart plus a timeframe input.
NWOG — same controls as the others, plus optional NWOG-specific bull/bear colour overrides.
Notes on usage
For NWOG live detection use a 1H or smaller intraday chart. On 4H+ charts the bar boundaries don't land on the 18:00 NY moment cleanly so new NWOGs won't form.
HTF FVGs appear on the chart at the bar where their HTF period closed, anchored back to the chart bars where the relevant HTF candle highs and lows occurred — this gives a clean "stepped" visual at the zone's left edge that shows how it formed.
The right edge of every zone tracks the current bar in real time. Set "Extend right beyond current bar" higher if you prefer a fixed runway.
TradingView caps total drawn objects at 500 lines / 500 boxes / 500 labels. With three lines per zone enabled across many sources at high display caps, you can hit those limits — drop the mid line first (it's off by default for that reason) and you double your headroom.
Built specifically for the way I trade GC futures on the 1H. Sharing because I haven't seen another FVG indicator that handles all three of these together: holiday-week NWOGs, four mitigation modes, and independent box/line control per source. Feedback welcome.
Release Note
Update notes (v2.12)Major rewrite of HTF FVG detection and a sweep of robustness improvements after live testing. Cleaner, more reliable, and louder when something's misconfigured.
Bug fixes
HTF FVGs now match across all chart TFs. Previous detection used a manual chart-bar-by-chart-bar tracker that produced different zones depending on the chart TF you were viewing — same 4H FVG could appear on the 15m chart but not the 1H, or anchor to the wrong bars. Replaced with request.security properly indexed at the HTF level. A 4H FVG now plots identically on 1H, 15m, 5m or any chart TF ≤ 4H.
NWOG anchoring fixed for holiday weeks. Previously stored Friday-only state went stale when COMEX closed for Good Friday / other holidays, producing wrongly-priced NWOG boxes anchored at the wrong bar. Now uses the previous chart bar's close on the Sunday 18:00 NY bar, which is always the actual last close before the weekend regardless of which weekday it fell on.
iFVG label flip on mitigation. When an FVG mitigates, its label now updates from e.g. 1H to 1H iFVG to mark it as an inverted FVG. NWOG labels stay as NWOG.
Right-edge extension fixed. Lines were extending infinitely instead of stopping at the current bar.
Mitigated zones can now hide their lines per source. Previous version recoloured them to grey only.
NWOG colour controls cleaned up. Two simple bull/bear colour pickers — set them the same for monochrome NWOGs, different to differentiate.
Labels simplified. Single global label colour. No "Bull"/"Bear" suffix on chart labels (still present in alert text).
New: configuration warnings
A single orange label appears on the last bar of the chart if any source/TF combination would silently fail or duplicate zones:
HTF1, HTF2, or HTF3 set below the chart TF (most zones missed)
HTF1, HTF2, or HTF3 matching the chart TF while Chart FVGs are also enabled (zones duplicate)
NWOG enabled on a chart TF that doesn't align to 18:00 NY (3H, 4H, daily, weekly, etc.)
The warning tells you exactly which source is misconfigured and why. Better than wondering why nothing's printing.
Visual
Box transparency default raised so fills are lighter / more readable.
Mid line off by default on Chart, HTF1, HTF2, HTF3, NWOG to save line slots.
Default colour scheme refreshed to match a slightly more saturated bull green and bear red.
HTF zone left edges retain the stepped anchor visual — top/bot lines start at the chart bars where the HTF candle's high/low actually occurred.
Defaults
Out-of-box settings on a 1H GC chart: Chart off, HTF1 = 4H (10 unfilled / 3 mitigated, lines hidden on mitigated), HTF2 / HTF3 off, NWOG on (2 unfilled / 3 mitigated, lines hidden on mitigated). Designed for clean session-trading layouts.
TF compatibility (quick reference)
Chart FVG: any chart TF
HTF1/2/3: chart TF ≤ HTF (warned if violated)
NWOG: chart TF ∈ {1m, 2m, 3m, 5m, 6m, 10m, 12m, 15m, 20m, 30m, 1H, 2H} (warned if violated)
Release Note
Hotfix: runtime error on chart bars where an HTF FVG anchor needed to walk back more than ~300 chart bars. Pine's default historical buffer is too small for that. Fixed by raising `max_bars_back` to 5000 and adding early termination in the anchor lookup once the walk-back passes the target HTF window. Verified working across 1H, 15m, 5m and 2m chart TFs.Release Note
Fix: HTF FVGs were printing on lower chart timeframes before the HTF candle had closed (e.g. a 1H FVG appearing on the 5m chart while the 1H bar was still forming). HTF data now reads from the previously-closed HTF bar only, guaranteeing every plotted zone is fully confirmed. Verified across 1m / 2m / 5m / 15m / 1H / 4H chart TFs against 1H / 4H / 1D / 1W HTFs.Also: improved fallback when an HTF anchor bar is older than the available chart history (extreme combos like 2m × weekly) — zones now stretch across the visible chart instead of rendering as a thin sliver at the right edge.
Release Note
Fixed: HTF FVG zones not transitioning to mitigated state when price wicked through them.Root cause: the request.security calls used a non-standard combination of [1] indexing with lookahead_off, which over-shifted HTF detection by one full HTF bar. Zones were being drawn one HTF bar late — by the time the zone was created, the chart bars that crossed its level had already been processed and could never be tested for mitigation again.
Fix: switched the six HTF request.security calls (HTF1/2/3, A and C bars each) to the documented non-repainting pattern of [1] indexing with lookahead_on. HTF FVGs now form on the chart bar at HTF close, in time for the next HTF window's price action to be tested for mitigation correctly. Architecture, pruning, anchor lookup, and all other prior fixes unchanged.
Note: HTF FVGs may appear marginally earlier than in v2.34 — this is correct behaviour, the previous version was drawing them late.
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน