Historical Data: 1H Edge NQ [Herman]

This Pine Script indicator is designed to provide traders with visual tools and historical statistical insights for analyzing hourly price behavior on the Nasdaq-100 futures (NQ) contract.
It focuses on key concepts such as Opening Ranges (OR) and Trading Windows (TW), drawing from established trading principles like session-based ranges and return probabilities.
This unique indicator stands out by incorporating pre-computed statistics derived from over 4 years of 1-minute timeframe data, offering detailed hourly probabilistic insights in an editable sticky note format—making it a distinctive tool for in-depth analysis.
The goal is to help users visualize potential price dynamics and assess historical tendencies, enabling more informed decision-making based on past data patterns.
All calculations are based on historical price action, and the indicator does not make predictions or generate trading signals—it simply displays pre-computed statistics and visual aids for educational and analytical purposes.
Key Features and Visual ElementsVertical Lines for Time Sessions:
Orange Line - Opening Range Midline (50%)
Horizontal Dotted Lines - Opening Range High and Low
Solid Red Line - Midnight Open
Dashed Vertical lines - Opening range and trading window start/close times
Blue Dashed Line - Trading Window Candle Open
The indicator marks the start of the user-selected Opening Range (OR) and Trading Window (TW) with customizable vertical lines.
These represent the time periods where the OR is formed (e.g., 02:00-03:00 NY time) and where trading activity is observed (e.g., 03:00-04:00 NY time).
Users can adjust these sessions via inputs for flexibility across different hours.
-Horizontal Lines for Price Levels:Opening Range High and Low:
-Solid or dashed lines (customizable) show the high and low of the selected OR, extended horizontally to highlight potential support/resistance levels during the TW.
-50% OR Midpoint: An optional dashed line at the midpoint (50%) of the OR, which serves as a reference for mean reversion analysis.
-Trading Window Open Price: A line marking the open price at the start of the TW, useful for tracking returns to this level.
-Midnight Open (Red Line): A dedicated red horizontal line indicating the open price at midnight (00:00 NY time), which acts as a daily reference point for overnight price action.
Statistical Display via Sticky Note and Table:A customizable "Sticky Note" table displays pre-computed backtest results for the selected OR hour, including sections for combined results, above-midnight scenarios, and below-midnight scenarios. Content is user-editable via inputs.
A main info table shows session details, total historical sessions, and probabilities for returns (if enabled).
Customization Options: Users can toggle visuals, adjust colors, styles, widths, positions, and themes (light/dark). The indicator supports up to 500 lines/labels/boxes for historical drawing.
Logic and PrincipleThe indicator operates on a per-hour basis, treating each hour (0-23 NY time) as an independent "session" for analysis:Session Definition:
For any given hour (e.g., 02:00), the OR is the high/low range formed in that hour.
The TW is the subsequent hour where price action is tracked.
Tracking Price Action: During the TW, the script checks if price "sweeps" (crosses) the OR high or low. It then monitors for "returns"—instances where price crosses back to the TW open price or the 50% midpoint of the OR after a sweep.
Statistical Calculation: Probabilities are derived from historical counts:Total sessions: Number of historical days where data was available for that hour.
Return to TW Open: Percentage of sessions where, after sweeping OR high/low, price returned to the TW open (calculated as returns / total sessions with sweeps).
Return to 50% OR: Similar percentage for returning to the OR midpoint.
These are computed cumulatively across all historical bars loaded on the chart, resetting flags daily to ensure independence per session. No real-time predictions are made; stats accumulate from past data.
Midnight Open Integration: The red line resets daily at 00:00 NY, providing context for overnight gaps or continuations.
Breakout Origin: Scans recent bars for conditions where a breakout from OR occurs without opposite direction breach, drawing lines to the origin bar's open for visual reference.
The core principle is rooted in range-based analysis, a common technical approach where traders observe how price interacts with session highs/lows and midpoints.
By quantifying historical return rates after sweeps, the indicator highlights tendencies like mean reversion or continuation, but all insights are retrospective and depend on the loaded data.
Data Source and BacktestingThe statistical data embedded in the sticky notes (e.g., return percentages, sweep rates) was generated using Python in a Jupyter Notebook environment.
It analyzes approximately 1089 days (about 4 years) of 1-minute historical data for NQ futures, sourced BacktestMarket.
The backtests focused on NY time sessions, calculating metrics like:Sweep rates (e.g., first sweep high after above-midpoint open).
Return probabilities post-sweep.
Conditional splits (above/below midnight open).
These pre-computed values are hardcoded into the script via text areas for display, ensuring transparency.
Note: Historical performance is not indicative of future results; this is for analytical reference only.
Purpose and UsageThis indicator aims to assist traders in evaluating price direction potential by combining visual session markers with historical probabilities.
For example:If historical data shows a high probability of returning to the 50% OR after a sweep, it might suggest monitoring for mean reversion.
-Automatic Backtesting result sticky note selection
-Opening Range Quarters
Script su invito
Solo gli utenti approvati dall'autore possono accedere a questo script. È necessario richiedere e ottenere l'autorizzazione per utilizzarlo. Tale autorizzazione viene solitamente concessa dopo il pagamento. Per ulteriori dettagli, seguire le istruzioni dell'autore riportate di seguito o contattare direttamente helmans13.
TradingView NON consiglia di pagare o utilizzare uno script a meno che non ci si fidi pienamente del suo autore e non si comprenda il suo funzionamento. Puoi anche trovare alternative gratuite e open-source nei nostri script della comunità.
Istruzioni dell'autore
Attenzione: prima di richiedere l'accesso, leggi la nostra guida per gli script su invito.
Declinazione di responsabilità
Script su invito
Solo gli utenti approvati dall'autore possono accedere a questo script. È necessario richiedere e ottenere l'autorizzazione per utilizzarlo. Tale autorizzazione viene solitamente concessa dopo il pagamento. Per ulteriori dettagli, seguire le istruzioni dell'autore riportate di seguito o contattare direttamente helmans13.
TradingView NON consiglia di pagare o utilizzare uno script a meno che non ci si fidi pienamente del suo autore e non si comprenda il suo funzionamento. Puoi anche trovare alternative gratuite e open-source nei nostri script della comunità.
Istruzioni dell'autore
Attenzione: prima di richiedere l'accesso, leggi la nostra guida per gli script su invito.