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
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.