OPEN-SOURCE SCRIPT
Silver Bullet & First/Last FVG

It is designed around the popular ICT (Inner Circle Trader) "Silver Bullet" concepts. Its main purpose is to highlight specific time-based trading windows on your chart and automatically detect and isolate the most significant Fair Value Gaps (FVGs) that form within those windows.
Here is a breakdown of its functionality:
1. Specific Time Sessions
The script monitors three specific 1-hour time windows (defaulting to New York time, but adjustable):
London Silver Bullet: 03:00 - 04:00
New York AM Silver Bullet: 10:00 - 11:00
New York PM Silver Bullet: 14:00 - 15:00
Each of these sessions can be toggled on/off individually, and their border colors customized.
2. Session Range Highlighting
When one of these 1-hour sessions begins, the script starts tracking the absolute Highest and Lowest price reached during that hour.
Once the session ends, it draws a large, semi-transparent box encapsulating that entire 1-hour price action range.
The box is labeled in the bottom right corner (e.g., "Lon SB" or "NY AM SB") so you can easily visually identify the Silver Bullet hour in hindsight.
3. First and Last FVG Detection
This is the most unique feature of the script. While standard indicators highlight every FVG, this script filters them based on the Silver Bullet sessions:
It continuously looks for standard 3-candle Fair Value Gaps (both bullish and bearish).
However, it only plots FVGs if they occur inside one of the active Silver Bullet sessions.
Furthermore, to reduce clutter, it only stores and plots the First FVG and the Last FVG that formed during that specific 1-hour window.
It automatically extends the boxes of these specific FVGs to match the right edge (end time) of the Silver Bullet session box.
4. Memory and Optimization
To prevent TradingView from throwing "too many drawings" errors or causing lag on your chart:
It uses a custom data structure (SBSessionData) to manage the state of each session cleanly.
At the start of every new day, it runs a cleanup function (clearDrawings()) that deletes older session boxes and FVGs if they exceed the user-defined sb_lookback limit (default 100 historical boxes).
Here is a breakdown of its functionality:
1. Specific Time Sessions
The script monitors three specific 1-hour time windows (defaulting to New York time, but adjustable):
London Silver Bullet: 03:00 - 04:00
New York AM Silver Bullet: 10:00 - 11:00
New York PM Silver Bullet: 14:00 - 15:00
Each of these sessions can be toggled on/off individually, and their border colors customized.
2. Session Range Highlighting
When one of these 1-hour sessions begins, the script starts tracking the absolute Highest and Lowest price reached during that hour.
Once the session ends, it draws a large, semi-transparent box encapsulating that entire 1-hour price action range.
The box is labeled in the bottom right corner (e.g., "Lon SB" or "NY AM SB") so you can easily visually identify the Silver Bullet hour in hindsight.
3. First and Last FVG Detection
This is the most unique feature of the script. While standard indicators highlight every FVG, this script filters them based on the Silver Bullet sessions:
It continuously looks for standard 3-candle Fair Value Gaps (both bullish and bearish).
However, it only plots FVGs if they occur inside one of the active Silver Bullet sessions.
Furthermore, to reduce clutter, it only stores and plots the First FVG and the Last FVG that formed during that specific 1-hour window.
It automatically extends the boxes of these specific FVGs to match the right edge (end time) of the Silver Bullet session box.
4. Memory and Optimization
To prevent TradingView from throwing "too many drawings" errors or causing lag on your chart:
It uses a custom data structure (SBSessionData) to manage the state of each session cleanly.
At the start of every new day, it runs a cleanup function (clearDrawings()) that deletes older session boxes and FVGs if they exceed the user-defined sb_lookback limit (default 100 historical boxes).
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.