OPEN-SOURCE SCRIPT
First Presented FVG

Summary: First Presented FVG Indicator
This is aPine Script® TradingView indicator that identifies and visualizes the first Fair Value Gap (FVG) that forms within configurable time windows during a trading session.
What it Does
1. Detects FVGs: Uses the classic 3-candle FVG definition:
- Bullish FVG: When low[0] > high[2] (gap up)
- Bearish FVG: When high[0] < low[2] (gap down)
2. "First Presented" Logic: For each configured time slot, it captures only the first qualifying FVG that forms—subsequent FVGs in that window are ignored.
3. Visual Display:
- Draws a colored box spanning from detection time to session end
- Optional text label showing detection time (e.g., "9:38 Tue FP FVG")
- Optional grade lines at 25%, 50%, and 75% levels within the FVG
Key Configuration
Setting Description
Timeframe Only works on 5-minute charts or lower
Timezone IANA timezone for session times (default: America/New_York)
Session Futures trading hours (default: 1800-1715)
Min FVG Size Minimum gap size in ticks to qualify
4 Time Slots Each with enable toggle, time window, and color
Default Time Slots
Technical Features
This is a
Pine Script v6
What it Does
1. Detects FVGs: Uses the classic 3-candle FVG definition:
- Bullish FVG: When low[0] > high[2] (gap up)
- Bearish FVG: When high[0] < low[2] (gap down)
2. "First Presented" Logic: For each configured time slot, it captures only the first qualifying FVG that forms—subsequent FVGs in that window are ignored.
3. Visual Display:
- Draws a colored box spanning from detection time to session end
- Optional text label showing detection time (e.g., "9:38 Tue FP FVG")
- Optional grade lines at 25%, 50%, and 75% levels within the FVG
Key Configuration
Setting Description
Timeframe Only works on 5-minute charts or lower
Timezone IANA timezone for session times (default: America/New_York)
Session Futures trading hours (default: 1800-1715)
Min FVG Size Minimum gap size in ticks to qualify
4 Time Slots Each with enable toggle, time window, and color
Default Time Slots
- Slot 1 (enabled): 09:30-10:30 — lime green
- Slot 2 (enabled): 13:30-14:30 — blue
- Slot 3 (disabled): 13:00-13:30 — teal
- Slot 4 (disabled): 14:15-14:45 — fuchsia
Technical Features
- Handles cross-midnight sessions correctly
- Resets all drawings at each new session
- Skips the first bar of each window to ensure valid 3-candle lookback
- Clamps slot windows to session boundaries
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.
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.
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.