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
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.