OPEN-SOURCE SCRIPT
Zaktualizowano Window Sniper FVG

# Window Sniper FVG [MTSY⁺] — TradingView Yayın Açıklaması (Taslak)
---
## OVERVIEW
**Window Sniper FVG** finds the *first* Fair Value Gap that forms inside any number of user-defined intraday time windows — and it does this on a timeframe completely independent from your chart's timeframe.
Most "session + FVG" tools on TradingView either (a) hard-code their sessions to a single well-known killzone setup, or (b) detect every FVG that occurs without anchoring them to a specific time window. This script does neither: it lets you define **up to three independent time windows** (start time, end time, color, and label — all freely editable), and inside each window it isolates the **single first FVG** that forms there — discarding any subsequent gaps in the same window. The result is a script equally useful for ICT-style Silver Bullet trading, for custom 4-hour candle opens, for session-open killzones on indices, or for any other recurring intraday window a trader wants to study.
## WHY THIS IS A MASHUP, AND WHY IT'S JUSTIFIED
This script combines two distinct mechanisms that, on their own, solve only half the problem traders actually face:
1. **Session/window visualization** — drawing a box or strip that marks when a custom time window is active on the chart (so the trader has a visual anchor for "this is the session I'm watching").
2. **First-gap-per-window detection** — a state machine that resets at the start of every new window and locks onto the first FVG formed inside it, running entirely inside `request.security()` so the detection timeframe (e.g., 5min or 15min) is independent of whatever timeframe the chart itself is displaying.
Neither piece is useful in isolation for this specific workflow: a session marker without FVG detection is just a colored box, and an FVG detector without session-awareness cannot tell a trader *which* gap, among dozens per day, is the one that matters for their specific time-of-day model. The combination is what turns this into a single coherent tool: open the chart, see the window, see the one gap that defines it.
## KEY FEATURES (what makes this different from existing FVG scripts)
- **Not limited to Silver Bullet** — the three windows ship with the ICT Silver Bullet defaults (London Open 03:00-04:00, NY AM 10:00-11:00, NY PM 14:00-15:00), but every session is a free-form time input. Use it for 4-hour candle opens, custom killzones, economic-release windows, or any other recurring intraday period — the underlying logic doesn't know or care that the defaults happen to be Silver Bullet hours.
- **First-gap-per-window, not every gap** — inside each active window, the script locks onto the first Fair Value Gap that forms and ignores every subsequent gap until the next window starts. This mirrors how ICT-style traders actually use a killzone: one defining imbalance per session, not a cluttered feed of every 3-candle gap.
- **Independent FVG detection timeframe** — the FVG search runs on a timeframe you choose (default 5 minutes), completely decoupled from your chart's timeframe. Stay on a 15min or 1H chart for your overall read, while the script quietly finds the first 5min (or 1min, or whatever you set) gap inside each window in the background.
- **Configurable time zone** — session times are evaluated against a UTC-offset you select (UTC-5 through UTC+9, including Istanbul/Moscow at UTC+3), so the tool isn't tied to New York sessions and works for traders centered on other markets.
- **Color-coded by window, bordered by direction** — each FVG's fill color matches the window it formed in (so you can tell at a glance which session produced it), while the border color and an optional arrow in the label indicate bullish vs. bearish direction.
- **Two distinct window visualization styles** — display windows as a price-hugging box that grows with the session's range ("Label" style), or as a fixed strip offset from price by a multiple of the daily ATR ("Top"/"Bottom" style) for a cleaner, less chart-intrusive look.
## HOW TO USE IT
1. Pick the time zone matching the market you trade (General settings).
2. Enable or disable each of the three windows and set their start/end time, color, and label text. The defaults are ICT Silver Bullet hours, but you can repurpose them for any recurring session.
3. Set the FVG detection timeframe (default 5min) — this is independent of your chart's timeframe.
4. Watch each active window: the first Fair Value Gap that forms inside it gets boxed, colored by window and bordered by direction, and extends right until either price mitigates it, the trading day ends, or a fixed bar count is reached (your choice).
## CREDITS
This script's window-marking visualization is built on an open-source killzone-box concept originally shared by **joshuuu**, and its multi-timeframe "first gap per interval" detection architecture is adapted from the open-source **"Cozy 1st FVG [MMT]"** script. Both components were substantially rewritten and extended: the fixed automatic interval logic was replaced with fully user-configurable, independently toggleable time windows; a configurable time zone selector was added; the visual system (window-colored fills, direction-colored borders, auto-contrast label text, two distinct window display styles) is original work; and the two previously separate mechanisms were integrated into a single coherent first-gap-per-window pipeline. Thank you to both original authors for the groundwork.
## DISCLAIMER
This script is provided for educational and informational purposes only. It does not constitute financial, investment, or trading advice. Fair Value Gaps and time-window analysis are descriptive tools for studying price behavior, not predictive signals or a guaranteed edge. Past behavior of price around these zones does not guarantee future results. Trade at your own risk.
---
---
## OVERVIEW
**Window Sniper FVG** finds the *first* Fair Value Gap that forms inside any number of user-defined intraday time windows — and it does this on a timeframe completely independent from your chart's timeframe.
Most "session + FVG" tools on TradingView either (a) hard-code their sessions to a single well-known killzone setup, or (b) detect every FVG that occurs without anchoring them to a specific time window. This script does neither: it lets you define **up to three independent time windows** (start time, end time, color, and label — all freely editable), and inside each window it isolates the **single first FVG** that forms there — discarding any subsequent gaps in the same window. The result is a script equally useful for ICT-style Silver Bullet trading, for custom 4-hour candle opens, for session-open killzones on indices, or for any other recurring intraday window a trader wants to study.
## WHY THIS IS A MASHUP, AND WHY IT'S JUSTIFIED
This script combines two distinct mechanisms that, on their own, solve only half the problem traders actually face:
1. **Session/window visualization** — drawing a box or strip that marks when a custom time window is active on the chart (so the trader has a visual anchor for "this is the session I'm watching").
2. **First-gap-per-window detection** — a state machine that resets at the start of every new window and locks onto the first FVG formed inside it, running entirely inside `request.security()` so the detection timeframe (e.g., 5min or 15min) is independent of whatever timeframe the chart itself is displaying.
Neither piece is useful in isolation for this specific workflow: a session marker without FVG detection is just a colored box, and an FVG detector without session-awareness cannot tell a trader *which* gap, among dozens per day, is the one that matters for their specific time-of-day model. The combination is what turns this into a single coherent tool: open the chart, see the window, see the one gap that defines it.
## KEY FEATURES (what makes this different from existing FVG scripts)
- **Not limited to Silver Bullet** — the three windows ship with the ICT Silver Bullet defaults (London Open 03:00-04:00, NY AM 10:00-11:00, NY PM 14:00-15:00), but every session is a free-form time input. Use it for 4-hour candle opens, custom killzones, economic-release windows, or any other recurring intraday period — the underlying logic doesn't know or care that the defaults happen to be Silver Bullet hours.
- **First-gap-per-window, not every gap** — inside each active window, the script locks onto the first Fair Value Gap that forms and ignores every subsequent gap until the next window starts. This mirrors how ICT-style traders actually use a killzone: one defining imbalance per session, not a cluttered feed of every 3-candle gap.
- **Independent FVG detection timeframe** — the FVG search runs on a timeframe you choose (default 5 minutes), completely decoupled from your chart's timeframe. Stay on a 15min or 1H chart for your overall read, while the script quietly finds the first 5min (or 1min, or whatever you set) gap inside each window in the background.
- **Configurable time zone** — session times are evaluated against a UTC-offset you select (UTC-5 through UTC+9, including Istanbul/Moscow at UTC+3), so the tool isn't tied to New York sessions and works for traders centered on other markets.
- **Color-coded by window, bordered by direction** — each FVG's fill color matches the window it formed in (so you can tell at a glance which session produced it), while the border color and an optional arrow in the label indicate bullish vs. bearish direction.
- **Two distinct window visualization styles** — display windows as a price-hugging box that grows with the session's range ("Label" style), or as a fixed strip offset from price by a multiple of the daily ATR ("Top"/"Bottom" style) for a cleaner, less chart-intrusive look.
## HOW TO USE IT
1. Pick the time zone matching the market you trade (General settings).
2. Enable or disable each of the three windows and set their start/end time, color, and label text. The defaults are ICT Silver Bullet hours, but you can repurpose them for any recurring session.
3. Set the FVG detection timeframe (default 5min) — this is independent of your chart's timeframe.
4. Watch each active window: the first Fair Value Gap that forms inside it gets boxed, colored by window and bordered by direction, and extends right until either price mitigates it, the trading day ends, or a fixed bar count is reached (your choice).
## CREDITS
This script's window-marking visualization is built on an open-source killzone-box concept originally shared by **joshuuu**, and its multi-timeframe "first gap per interval" detection architecture is adapted from the open-source **"Cozy 1st FVG [MMT]"** script. Both components were substantially rewritten and extended: the fixed automatic interval logic was replaced with fully user-configurable, independently toggleable time windows; a configurable time zone selector was added; the visual system (window-colored fills, direction-colored borders, auto-contrast label text, two distinct window display styles) is original work; and the two previously separate mechanisms were integrated into a single coherent first-gap-per-window pipeline. Thank you to both original authors for the groundwork.
## DISCLAIMER
This script is provided for educational and informational purposes only. It does not constitute financial, investment, or trading advice. Fair Value Gaps and time-window analysis are descriptive tools for studying price behavior, not predictive signals or a guaranteed edge. Past behavior of price around these zones does not guarantee future results. Trade at your own risk.
---
Informacje o Wersji
🔧 Pine Script v6'ya geçiş — Script artık TradingView'ın güncel yayın gereksinimleriyle uyumlu.⚙️ Window Settings sadeleştirildi — Strip Height, Offset from price, Label Text Size, Daily ATR Length ve Label Text Color artık tek bir ortak ayar grubundan, her üç Window Style'da (Label/Top/Bottom) aynı şekilde çalışıyor. Daha önce bu ayarlar sadece Top/Bottom modunda etkiliydi, artık Label modu da aynı ATR bazlı boyutlandırmayı kullanıyor.
📏 Offset from price artık Label modunda da aktif — Pencere etiketleri artık fiyata yapışık değil, ayarlanabilir bir mesafede duruyor (varsayılan 0.06x Daily ATR).
🎨 Tek noktadan etiket rengi kontrolü — Pencere etiketleri ve FVG etiketleri artık aynı "Label Text Color" ayarından (Auto B/W veya Manual) besleniyor, ayrı ayrı ayarlamaya gerek kalmadı.
🐛 Hata düzeltmeleri — Filtre kapalıyken bile pencerelerin aktif görünmesine sebep olan boolean mantık hatası giderildi; FVG tespitinin chart'ın kendi timeframe'i ile çakıştığında (örn. 5 dakikalık chart'ta 5 dakikalık FVG araması) çalışmama sorunu düzeltildi.
---
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.