OPEN-SOURCE SCRIPT

NQ Hourly Retracements - 12y Stats with Levels

604
Hour Stats with Levels - TradingView Indicator Description
IMPORTANT: NQ FUTURES ONLY
This indicator is specifically designed for and calibrated to NQ (Nasdaq-100 E-mini) futures only. The statistical data is derived exclusively from 13 years of NQ price action (2013-2025). Do not use this indicator on any other asset, ticker, or market as the statistics will not be applicable and may lead to incorrect trading decisions.

Overview
"Hour Stats with Levels" is a statistical analysis indicator that provides real-time probability-based insights into hourly price behavior patterns. The indicator combines historical pattern recognition with live price action to help traders anticipate potential sweep and reversal scenarios within each trading hour.

Originality and Core Concept
This indicator is based on a comprehensive statistical analysis of 12y years of 1-minute NQ futures data, examining a specific price pattern: when an hourly candle opens inside the previous hour's range. Unlike generic support/resistance indicators, this tool provides hour-specific, context-aware probabilities based on 30,000+ historical occurrences of this pattern.

The originality lies in three key areas:

Pattern-Specific Statistics: Rather than applying generic technical analysis, the indicator only activates when the current hour opens within the previous hour's range, providing relevant statistics for this exact scenario.

Context-Aware Probabilities: Statistics are differentiated based on whether the current hour opened above or below the previous hour's open, recognizing that bullish and bearish opening contexts produce different behavioral patterns.

Comprehensive Retracement Tracking: The indicator tracks four independent retracement levels after a sweep occurs, showing the probability of price returning to: the swept level itself (90+% probability), the 50% level, the current hour's open, and the opposite extreme.

How It Works
The Core Pattern
The indicator monitors a specific price structure:

Setup Condition: The current hourly candle opens inside (between) the previous hour's high and low
Sweep Event: Price then breaks above the previous high (high sweep) or below the previous low (low sweep)
Retracement Analysis: After a sweep, the indicator tracks whether price retraces to key levels

Statistical Foundation
The underlying analysis processed 1-minute bar data from 2013-2025, identifying every instance where an hourly candle opened inside the previous hour's range. For each occurrence, the system tracked:

Whether the high, low, or both were swept during that hour
The distance of the sweep measured as a percentage of the previous hour's range
Whether price retraced to four key levels: the swept level, the 50% point, the current open, and the opposite extreme

These measurements were aggregated for all 24 hours of the trading day, with separate statistics for bullish contexts (opening above previous open) and bearish contexts (opening below previous open), creating 48 unique statistical profiles.

Sweep Distance Percentiles
The "reversal levels" are drawn based on historical sweep distance distributions:
25th Percentile: 75% of historical sweeps were larger than this distance. This represents a conservative reversal zone where smaller, contained sweeps typically reverse.
Median (50th Percentile): The midpoint of all historical sweep distances. Half of all sweeps reversed before reaching this level, half extended beyond it.
75th Percentile: Only 25% of sweeps extended beyond this distance. This represents an extended sweep zone where price has historically shown exhaustion.

For example, if the previous hour's range was 20 points and the median high sweep distance is 40% of range, the median reversal level would be placed 8 points above the previous high.

How to Use the Indicator
Sweeps were calculated using 1m data - as such, it's recommended to use the indicator on a 1min chart

Visual Components
Hour Delimiter (Gray Vertical Line)
Marks the start of each new hour
Helps identify when new statistics become active

Sweep Markers
Green "H" label: High sweep has occurred this hour
Red "L" label: Low sweep has occurred this hour
Markers appear on the exact bar where the sweep happened

Target Levels (Blue Lines)
Prev Open: Previous hour's opening price
Prev High: Previous hour's highest price (sweep target)
Prev Low: Previous hour's lowest price (sweep target)
Prev 50%: Midpoint of previous hour's range
Current Open: Current hour's opening price (key retracement target)

Reversal Levels (Purple Dashed Lines)
Positioned beyond the previous high/low based on historical sweep percentiles
Three levels above previous high (for high sweeps)
Three levels below previous low (for low sweeps)
These represent statistically-derived zones where sweeps typically exhaust

The Statistics Table
The table dynamically updates each hour and displays different statistics based on whether the current hour opened above or below the previous hour's open.

Status Row
Shows current state: waiting for sweep, or which sweep(s) have occurred
If waiting, indicates which sweep is more probable based on historical data

SWEEP PROBABILITIES Section

High Sweep: Historical probability (%) that price will sweep the previous high this hour
Low Sweep: Historical probability (%) that price will sweep the previous low this hour
Both Sweeps: Historical probability (%) that price will sweep both levels this hour

These probabilities are derived from counting how many times each pattern occurred in similar historical contexts. For example, "High Sweep: 73.18%" means that in 73.18% of historical occurrences where the hour opened in this same context (same hour of day, same position relative to previous open), price swept the previous high before the hour closed.

AFTER HIGH SWEEP → Section
These statistics activate only after a high sweep has occurred. They show the probability of price retracing to various levels:

→ Prev High: Probability that price returns to (or below) the level it just swept. This is typically 90%+ because sweeps often act as "false breakouts" or liquidity grabs before reversal.
→ 50% Level: Probability that price retraces at least halfway back into the previous hour's range. This represents a moderate retracement.
→ Current Open: Probability that price retraces all the way back to where the current hour opened. This indicates a complete reversal of the sweep move.
→ Prev Low: Probability that price retraces entirely through the previous range to touch the opposite extreme. This represents a full reversal pattern.

AFTER LOW SWEEP → Section
Mirror of the above, but for low sweeps:

→ Prev Low: Retracement to the swept low level (90%+ probability)
→ 50% Level: Retracement to middle of range
→ Current Open: Full retracement to current hour's open
→ Prev High: Complete reversal to opposite extreme

Important Note on Retracement Statistics: These percentages are tracked independently. A 90% probability of returning to the swept level doesn't mean there's only a 10% chance of deeper retracement. Price can (and often does) retrace through multiple levels sequentially. The percentages show how many times price reached at least that level, not where it stopped.

Trading Applications
Anticipating Sweeps
When an hour opens inside the previous range, check the probabilities. If "High Sweep: 70%" and "Low Sweep: 30%", you know there's a 70% historical likelihood of an upside sweep occurring this hour. This doesn't guarantee it will happen, but provides statistical context for potential setups.

Reversal Trading
The most reliable pattern in the data is the 90%+ retracement probability to swept levels. When a sweep occurs, traders can anticipate a retracement back to at least the swept level in the vast majority of cases. The reversal level percentiles help identify where sweeps may exhaust.

Position Management
The retracement probabilities help manage existing positions. For example, if you're long and a high sweep occurs, you know there's a 90%+ chance of at least some retracement to the swept level, which might inform profit-taking or stop-loss decisions.

Confluence with Current Open
The "Current Open" retracement statistics (typically 60-70%) highlight the magnetic quality of the hour's opening price. After a sweep, price frequently returns to test this level.

Customization Options
The indicator offers extensive visual customization:
Toggle on/off: hour delimiters, sweep markers, target levels, reversal levels, statistics table
Customize colors, line widths, and styles for all visual elements
Adjust label sizes and table position
Show/hide individual target levels and reversal percentiles

Limitations and Considerations

Pattern-Specific: The indicator only provides statistics when the current hour opens inside the previous hour's range. If the hour opens outside this range (gaps up or down), the statistics are not applicable.

Historical Probabilities: The percentages represent historical frequencies, not predictions. A 70% probability means it happened 70% of the time historically, not that it will definitely happen 7 out of 10 times going forward.

NQ-Specific Calibration: All statistics are derived from NQ futures data. Market behavior, volatility, and patterns differ across assets.

Hour-Specific Behavior: Different hours show dramatically different statistics. For example, the 9 AM EST hour (market open) shows much higher sweep probabilities (80%+) than the 5 PM EST hour (30-50%) due to differing liquidity and volatility conditions.

No Guarantee of Execution: While a 90% retracement probability is high, it means 10% of the time, price did NOT retrace. Always use proper risk management.

Technical Notes
The indicator uses hourly timeframe data via request.security() to determine previous hour values
Sweep detection occurs in real-time on the chart's timeframe
Statistics are hardcoded from the comprehensive backtested analysis (not calculated on-the-fly)
The indicator stores static values at the start of each hour to ensure consistency as the hour progresses
All percentage values are rounded to one decimal place for clarity


This indicator provides a statistically-grounded framework for understanding hourly price behavior in NQ futures. By combining real-time pattern detection with comprehensive historical analysis, it offers traders probabilistic insights to inform decision-making process within the specific context of each trading hour.

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.