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 de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que la republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como asesoramiento o recomendaciones financieras, de inversión, de trading o de otro tipo proporcionadas o respaldadas por TradingView. Más información en Condiciones de uso.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que la republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como asesoramiento o recomendaciones financieras, de inversión, de trading o de otro tipo proporcionadas o respaldadas por TradingView. Más información en Condiciones de uso.