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
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.