OPEN-SOURCE SCRIPT

First presented FVG (w/stats) w/statistical hourly ranges & bias

1 303
Overview
This indicator identifies the first Fair Value Gap (FVG) that forms during each hourly session and provides comprehensive statistical analysis based on 12 years of historical NASDAQ (NQ) data. It combines price action analysis with probability-based statistics to help traders make informed decisions.

⚠️ IMPORTANT - Compatibility

Market: This indicator is designed exclusively for NASDAQ futures (NQ/MNQ)
Timeframe: Statistical data is based on FVGs formed on the 5-minute timeframe
FVG Detection: Works on any timeframe, but use 5-minute for accuracy matching the statistical analysis
All hardcoded statistics are derived from 12 years of NQ historical data


What It Does
1. FVG Detection & Visualization

Automatically detects the first FVG (bullish or bearish) that forms each hour
Draws colored boxes around FVGs:

Blue boxes = Bullish FVG (gap up)
Red boxes = Bearish FVG (gap down)


FVG boxes extend to the end of the hour
Optional midpoint lines show the center of each FVG
Uses volume imbalance logic (outside prints) to refine FVG boundaries

2. Hourly Reference Lines

Vertical Delimiter: Marks the start of each hour
Hourly Open Line: Shows where the current hour opened
Expected Range Lines: Projects the anticipated high/low based on historical data

Choose between Mean (average) or Median (middle value) statistics
Upper range line (teal/green)
Lower range line (red)


All lines span exactly one hour from the moment it opens
Optional labels show price values at line ends

3. Real-Time Statistics Table
The table displays live data for the current hour only:

Hour: Current hour in 12-hour format (AM/PM)
FVG Status: Shows if a Bull FVG, Bear FVG, or no FVG has formed yet

Green background = Bullish FVG detected
Red background = Bearish FVG detected


1st 15min: Direction of the first 15 minutes (Bullish/Bearish/Neutral/Pending)
Continuation %: Historical probability that the hour continues in the first 15-minute direction

Color-coded: Green for bullish, red for bearish


Avg Range %: Expected percentage range for the current hour (based on 12-year mean)
FVG Effect %: Historical probability that FVG direction predicts hourly close direction

Shows BISI→Bull % for bullish FVGs
Shows SIBI→Bear % for bearish FVGs
Blank if no FVG has formed yet


Time Left: Countdown timer showing MM:SS remaining in the hour (updates in real-time)
Hourly Bias: Historical directional tendency (bullish % or bearish %)
H Open: Current hour's opening price
Exp Range: Projected price range (Low - High) based on historical average


Customization Options
Detection Settings:

Lower Timeframe Selection (15S, 1min, 5min) - controls FVG detection granularity

Display Settings:

FVG box colors (bullish/bearish)
Midpoint lines (show/hide, color, style)

Table Settings:

Position (9 locations: corners, edges, center)
Text size (Tiny, Small, Normal, Large)

Hourly Lines:

Toggle each line type on/off
Hour delimiter (color, width)
Open line (color, width, style)
Range lines (color, width, style)
Choose Mean or Median statistics for range calculation
Show/hide labels with customizable text size


How to Use

Apply to NQ futures chart (NQ1! or MNQ1!)
Set chart to 5-minute timeframe for optimal FVG detection matching the statistical data
Watch for the first FVG to form each hour
Reference the table for probability-based decision support:

High continuation % = strong directional bias
FVG Effect % shows reliability of the FVG signal
Time Left helps manage entries/exits within the hour


Use range lines as potential targets or reversal zones


Statistical Foundation
All statistics are derived from:

12 years of NASDAQ (NQ) historical data
Hourly analysis of FVG formation patterns
First 15-minute directional analysis
Mean and Median calculations for range expectations
Data encompasses 2,400+ samples per hour


Best Practices

✅ Use on NQ/MNQ futures only
✅ Best on 5-minute charts (matches statistical data)
✅ Combine FVG signals with continuation probabilities
✅ Use range lines as potential profit targets
✅ Watch the countdown timer for hour-end setups
❌ Do not use on other markets (statistics won't apply)
❌ Avoid using during low-liquidity hours (5PM ET has minimal data)


Technical Notes

Timezone: America/New_York (EST/EDT)
Weekend filtering: Automatically hides data during market closure
Updates in real-time on live bars
Maximum 500 boxes/lines for performance
FVG detection includes volume imbalance (body gap) refinement


Credits
Statistical analysis based on 12 years of NASDAQ historical data. FVG detection methodology follows ICT concepts with volume imbalance refinement.

Disclaimer: This indicator provides statistical analysis based on historical data. Past performance does not guarantee future results. Always use proper risk management.

Would you like me to adjust any section or add/remove anything?6-9 Session & Levels - Customizable Range Analysis Indicator

Description:
This indicator provides comprehensive session-based range analysis designed for intraday traders. It calculates and displays key levels based on a customizable session period (default 6:00-9:00 AM ET).
Core Features:
Sespastedthis is a summary for another indicator- i was hoping for something more like this in terms of content etc22:23Architected comprehensive indicator summary matching professional documentation style.The user wants me to rewrite the summary for their FVG indicator in a similar style to the example provided. The example is more structured, detailed, and professional. Let me create a comprehensive summary that follows that format:

Clear title
Description/Overview
Core Features (broken down into sections)
Input Settings Explained (detailed breakdown of all customization options)
How It Works section
Use Case
Note/Disclaimer

Let me make it thorough and match the style while being accurate to their indicator's functionality.Here's a detailed summary in that format:

Every Hour 1st FVG with Statistical Analysis - NASDAQ Hourly Trading Intelligence
Description:
This indicator identifies the first Fair Value Gap (FVG) that forms during each hourly session and provides comprehensive probability-based statistical analysis derived from 12 years of NASDAQ (NQ) historical data. It combines real-time FVG detection with hardcoded statistical probabilities to help intraday traders make informed decisions based on historical patterns and hourly price action dynamics.
IMPORTANT: This indicator is specifically calibrated for NASDAQ futures (NQ/MNQ) only. All statistical data is derived from 12 years of NQ historical analysis with FVGs detected on the 5-minute timeframe. Using this indicator on other markets will produce invalid statistical results.

Core Features:
FVG Detection & Visualization

Automatically detects and displays the first Fair Value Gap (bullish or bearish) that forms within each hourly session
Color-coded boxes mark FVG zones: Blue for bullish FVGs (gap up), Red for bearish FVGs (gap down)
FVG boxes extend precisely to the end of the hour boundary
Optional midpoint lines show the center point of each FVG
Uses volume imbalance logic (outside prints) to refine FVG boundaries beyond simple wick-to-wick gaps
Supports both chart timeframe detection and lower timeframe detection via request.security_lower_tf

Hourly Reference Lines

Vertical Hour Delimiter: Marks the exact start of each new hour with an extendable vertical line
Hourly Open Line: Displays the opening price of the current hour
Expected Range Lines: Projects anticipated high and low levels based on 12 years of statistical data

Choose between Mean (average) or Median (middle value) calculations
Upper range line shows expected high
Lower range line shows expected low


All lines span exactly one hour from open to close
Optional labels display exact price values at the end of each line

Real-Time Statistics Table
Displays comprehensive live data for the current hour only:

Hour: Current hour in 12-hour format (e.g., "9AM", "2PM")
FVG Status: Shows detection state with color coding

"None Yet" (white background) - No FVG detected
"Bull FVG" (green background) - Bullish FVG identified
"Bear FVG" (red background) - Bearish FVG identified


1st 15min: Direction of first 15 minutes (Bullish/Bearish/Neutral/Pending)
Continuation %: Historical probability that the hour closes in the direction of the first 15 minutes

Green background with up arrow (↑) for bullish continuation probability
Red background with down arrow (↓) for bearish continuation probability


Avg Range %: Expected percentage range for the current hour based on 12-year mean
FVG Effect %: Historical effectiveness of FVG directional prediction

Shows "BISI→Bull %" for bullish FVGs (gap up predicting bullish hourly close)
Shows "SIBI→Bear %" for bearish FVGs (gap down predicting bearish hourly close)
Displays blank if no FVG has formed yet


Time Left: Real-time countdown timer showing minutes and seconds remaining in the hour (MM:SS format)
Hourly Bias: Historical directional tendency showing bullish or bearish percentage bias
H Open: Current hour's opening price
Exp Range: Projected price range showing "Low - High" based on selected statistic (mean or median)


Input Settings Explained:
Detection Settings

Lower Timeframe: Select the base timeframe for FVG detection

Options: 15S (15 seconds), 1 (1 minute), 5 (5 minutes)
Recommendation: Use 5-minute to match the statistical data sample
The indicator uses this timeframe to scan for FVG patterns even when viewing higher timeframes



Display Settings

Bullish FVG Color: Set the color and transparency for bullish (upward) FVG boxes
Bearish FVG Color: Set the color and transparency for bearish (downward) FVG boxes
Show Midpoint Lines: Toggle horizontal lines at the center of each FVG box
Midpoint Line Color: Customize the midpoint line color
Midpoint Line Style: Choose between Solid, Dotted, or Dashed line styles

Table Settings

Table Position: Choose from 9 locations:

Top: Left, Center, Right
Middle: Left, Center, Right
Bottom: Left, Center, Right


Table Text Size: Select from Tiny, Small, Normal, or Large for readability on different screen sizes

Hourly Lines Settings

Show Hourly Lines: Master toggle for all hourly reference lines
Show Hour Delimiter: Toggle the vertical line marking each hour's start

Delimiter Color: Customize color and transparency
Delimiter Width: Set line thickness (1-5)


Show Hourly Open: Toggle the horizontal line at the hour's opening price

Open Line Color: Customize color
Open Line Width: Set thickness (1-5)
Open Line Style: Choose Solid, Dashed, or Dotted


Show Range Lines: Toggle the expected high/low projection lines

Range Statistic: Choose "Mean" (12-year average) or "Median" (12-year middle value)
Range High Color: Customize upper range line color and transparency
Range Low Color: Customize lower range line color and transparency
Range Line Width: Set thickness (1-5)
Range Line Style: Choose Solid, Dashed, or Dotted


Show Line Labels: Toggle price labels at the end of all horizontal lines

Label Text Size: Choose Tiny, Small, or Normal




How It Works:
FVG Detection Logic:
The indicator scans price action on the selected lower timeframe (default: 1-minute) looking for Fair Value Gaps using a 3-candle pattern:

Bullish FVG: Formed when candle [2]'s high is below candle [0]'s low, creating an upward gap
Bearish FVG: Formed when candle [2]'s low is above candle [0]'s high, creating a downward gap

The detection is refined using volume imbalance logic by checking for body gaps (outside prints) on both sides of the middle candle. This narrows the FVG zone to areas where bodies don't touch, indicating stronger imbalances.
Only the first FVG that forms during each hour is displayed. If a bullish FVG forms first, it takes priority. The FVG box is drawn from the formation time through to the end of the hour.
Statistical Analysis:
All probability statistics are hardcoded from 12 years (2,400+ samples per hour) of NASDAQ futures analysis:

First 15-Minute Direction: At 15 minutes into each hour, the indicator determines if price closed above, below, or equal to the hour's opening price
Continuation Probability: Historical analysis shows the likelihood that the hour closes in the same direction as the first 15 minutes

Example: If 9AM's first 15 minutes are bullish, there's a 60.1% chance the entire 9AM hour closes bullish (lowest continuation hour)
4PM shows the highest continuation at 86.1% for bullish first 15 minutes


FVG Effectiveness: Tracks how often the first FVG's direction correctly predicts the hourly close direction

BISI (Bullish Imbalance/Sell-side Inefficiency) → Bullish close probability
SIBI (Bearish Imbalance/Buy-side Inefficiency) → Bearish close probability


Range Expectations: Mean and median values represent typical price movement percentage for each hour

9AM and 10AM show the largest ranges (~0.6%)
5PM shows minimal range (~0.06%) due to low liquidity



Hourly Reference Lines:
When each new hour begins:

Vertical delimiter marks the hour's start
Hourly open line plots at the first bar's opening price
Range projection lines calculate expected high/low:

Upper Range = Hourly Open + (Range% / 100 × Hourly Open)
Lower Range = Hourly Open - (Range% / 100 × Hourly Open)


Lines extend exactly to the hour's end time
Labels appear at line endpoints showing exact prices

Real-Time Updates:

FVG Status: Updates immediately when the first FVG forms
First 15min Direction: Locked in at the 15-minute mark
Countdown Timer: Uses timenow to update every second
Table Statistics: Refresh on every bar close

Timezone Handling:

All times are in America/New_York (Eastern Time)
Automatically filters weekend periods (Saturday and Sunday before 6PM)
Hour detection accounts for daylight saving time changes


Use Cases:
Intraday Trading Strategy Development:

FVG Entry Signals: Use the first hourly FVG as a directional bias

Bullish FVG + High continuation % = Strong long setup
Bearish FVG + High continuation % = Strong short setup


First 15-Minute Breakout: Combine first 15-min direction with continuation probabilities

Wait for first 15 minutes to complete
If continuation % is above 70%, trade in that direction
Example: 4PM bullish first 15 min = 86.1% chance hour closes bullish


Range Targeting: Use expected high/low lines as profit targets or reversal zones

Price approaching mean high = potential resistance
Price approaching mean low = potential support
Compare mean vs median for different risk tolerance (median is more conservative)


Hour Selection: Focus trading on hours with:

High FVG effectiveness (11AM: 81.5% BISI→Bull)
High continuation rates (4PM: 86.1% bull continuation)
Avoid low-continuation hours like 9AM (60.1%)


Time Management: Use the countdown timer to:

Enter early in the hour when FVG forms
Exit before hour-end if no follow-through
Avoid late-hour entries with <15 minutes remaining



Statistical Edge Identification:

Compare current hour's FVG against historical effectiveness
Identify when first 15-min direction contradicts FVG direction (conflict = caution)
Use hourly bias to confirm or contradict FVG signals
Monitor if price stays within expected range or breaks out (outlier moves)

Risk Management:

Expected range lines provide logical stop-loss placement
FVG Effect % helps size positions (higher % = larger position)
Time Left countdown aids in time-based stop management
Avoid trading hours with neutral bias or low continuation rates


Statistical Foundation:
All embedded statistics are derived from:

12 years of NASDAQ futures (NQ) continuous contract data
5-minute timeframe FVG detection methodology
24 hours per day analysis (excluding weekends)
2,400+ samples per hour for robust statistical validity
America/New_York timezone for session alignment

Data includes:

Hourly range analysis (mean, median, standard deviation)
First 15-minute directional analysis
FVG formation frequency and effectiveness
Continuation probability matrices
Bullish/bearish bias percentages


Best Practices:
✅ Do:

Use exclusively on NASDAQ futures (NQ1! or MNQ1!)
Apply on 5-minute charts for optimal FVG detection matching statistical samples
Wait for first 15 minutes to complete before acting on continuation probabilities
Combine FVG signals with continuation % and FVG Effect % for confluence
Use expected range lines as initial profit targets
Monitor the countdown timer for time-based trade management
Focus on hours with high statistical edges (4PM, 11AM, 10AM)

❌ Don't:

Use on other markets (ES, RTY, YM, stocks, forex, crypto) - statistics will be invalid
Rely solely on FVG without confirming with continuation probabilities
Trade during low-liquidity hours (5PM shows only 0.06% average range)
Ignore the first 15-minute direction when it conflicts with FVG direction
Apply to timeframes significantly different from 5-minute for FVG detection
Use median range expectations aggressively (they're conservative)


Technical Implementation Notes:

Timezone: Fixed to America/New_York with automatic DST adjustment
Weekend Filtering: Automatically hides data Saturday and Sunday before 6PM ET
Performance: Maximum 500 boxes and 500 lines for optimal chart rendering
Update Frequency: Table updates on every bar close; timer updates every second using timenow
FVG Priority: Bullish FVGs take precedence when both form simultaneously
Lower Timeframe Detection: Uses request.security_lower_tf for accurate sub-chart-timeframe FVG detection
Precision: All price labels use format.mintick for appropriate decimal precision

Big thanks to Trades-Dont-Lie for the FPFVG code in his excellent indicator that I've used here

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.