OPEN-SOURCE SCRIPT
NQ Stats helper

The "NQ Stats Helper" aims to provide users with an all-in-one toolkit for trading Nasdaq futures, based on some of the metrics provided by NQ Stats. As such, its aim is to be a comprehensive Pine Script v5 indicator designed to assist traders in analysing key trading sessions (Asia, London, New York) and Regular Trading Hours (RTH) levels for instruments like the Nasdaq futures (NQ). It provides visual overlays, statistical tables, and correlation matrices to track session ranges, previous day/week levels, and time-based opens. The indicator is highly customizable, allowing users to toggle features, adjust time zones, and filter data to suit their trading strategies.
Features
Previous Day and Week Levels:
Displays previous day's high, low, and 50% midpoint with customizable colours and labels.
Optionally shows previous week's levels via filter options.
Trading Session Ranges:
Tracks Asia (00:00-07:00), London (07:00-12:45), and New York (13:00-22:00) sessions with configurable time zones.
Visualizes session ranges as boxes, with optional high/low lines and 50% Fibonacci midpoints.
Includes volume and ATR (average true range) stats for each session.
Time-Based Opens:
Plots Midnight Open (00:00) and an additional custom open (default 08:00) with adjustable styles and colours.
RTH Session Levels:
Monitors today’s RTH open, high, low, mid, and yesterday’s RTH open, close, high, low, mid.
Customizable session times (default 09:30-16:00) or use Day Session (08:00-16:00).
Statistical Tables:
Session Stats Table: Shows range, volume, ATR, high, mid, and low for each session.
Correlation Matrix: Displays historical counts of NY session engulfing states relative to London vs. Asia conditions.
Filtered Correlation Matrix: Filters the correlation matrix based on RTH open conditions (e.g., above/below a level or between yesterday’s RTH high/low).
Current Session State Table: Shows the current London vs. Asia engulfing state and whether NY’s RTH open is inside yesterday’s RTH range.
How to Use
Add the indicator to your chart (preferably on an intraday timeframe like 1m, 5m, or 15m for NQ futures), then configure the inputs in the settings panel to tailor it to your needs.
Input Settings
Previous Day Data
Show Previous Day Levels: Toggle visibility of previous day’s high, low, and 50% levels.
Previous Day High/Low/50% Colours: Customize the colours for these lines and labels.
Trading Sessions
New York/London/Asia:
Checkbox: Enable/disable each session.
Text: Rename the session (e.g., "New York" to "NY").
Session Time: Set the session time range (e.g., "1300-2200" for NY).
Colour: Choose the colour for session visuals and text.
Range: Show the session range as a box.
Max/Min: Plot high/low lines for the session.
Show 50% Level: Display the Fibonacci midpoint line.
UTC (+/-): Adjust the timezone offset (e.g., +5 for UTC+5). Use 0 for UTC.
Use Exchange Timezone: Override UTC setting with the chart’s exchange timezone.
Range Area Transparency: Set transparency of session range boxes (0 = opaque, 100 = fully transparent).
Range Outline: Toggle dotted outline for session boxes.
Range Label: Show session name labels above ranges.
Time Based Open
Session: Define the time for Midnight Open (default "0000-0001") and a second open (default "0800-0801").
Line Style: Choose Solid, Dotted, or Dashed for each line.
Colour: Set the colour for each open level.
Show Level: Toggle visibility of each time-based open line.
RTH Session Settings
Session Type: Select "Day Session (RTH)" (08:00-16:00) or "Custom" for user-defined times.
Custom Session: Set custom RTH times (e.g., "0930-1600") if "Custom" is selected.
Today’s RTH Session
Open/Mid/High/Low: Toggle visibility of today’s RTH levels.
Color: Customize the color for each level.
Width: Set line thickness (1-5).
Yesterday’s RTH Session
Open/Close/Mid/High/Low: Toggle visibility of yesterday’s RTH levels.
Colour: Customize the colour for each level.
Width: Set line thickness (1-5).
More Settings
Offset Labels N Bars Right: Move labels right by N bars (default 20).
Multiply Offset for Yesterday’s Labels: Scale the offset for yesterday’s labels (e.g., 1.5 = 50% further).
Label Size: Set size for all labels (Auto, Tiny, Small, Normal, Large, Huge).
Table Settings
Show Session Stats Table: Toggle the stats table.
Stats Table Position/Size/Style: Set position (e.g., "Top Right"), size (e.g., "Small"), and style (Light/Dark).
Show Correlation Matrix: Toggle the full correlation matrix.
Correlation Matrix Position/Size/Style: Configure position, size, and style.
Show Filtered Correlation Matrix: Toggle the filtered matrix.
Filtered Correlation Matrix Position/Size/Style: Configure position, size, and style.
Filter Direction: Choose "Above", "Below", or "Between Yesterday’s RTH High and Low" to filter data.
Filter Level: Select a level (e.g., "Midnight open", "London high") for Above/Below filters.
Show Current Session State Table: Toggle the current state table.
Current Session State Table Position/Size/Style: Configure position (default "Top Center"), size, and style.
Output Description
Chart Overlays:
Lines: Previous day levels, session highs/lows/mids, RTH levels, and time-based opens.
Boxes: Session ranges with customizable colours and transparency.
Labels: Price levels and names next to lines/boxes, offset to the right.
Tables:
Session Stats Table: Columns for Session, Range, Volume, ATR, High, Mid, Low for Asia, London, and NY.
Correlation Matrix: 5x5 grid showing NY engulfing states (Full, Part Up, Part Down, Inside) vs. London vs. Asia states, with total trading days.
Filtered Correlation Matrix: Same as above, but filtered by RTH open conditions (e.g., above Midnight Open).
Current Session State Table: 2x3 grid showing "London vs Asia" (current engulfing state) and "NY Open in Yest RTH Range" (Yes/No).
How to Interpret
Session Ranges: Use the boxes and high/low lines to identify key price zones for each session.
RTH Levels: Compare today’s and yesterday’s RTH levels for potential support/resistance.
Correlation Matrices: Analyse historical patterns (e.g., how often NY fully engulfs London when London engulfs Asia) to inform trading decisions.
Current State: Check the current London vs. Asia relationship and NY open position for real-time context.
Usage Tips
Apply on NQ futures or similar instruments with intraday data.
Adjust session times and timezone to match your market (e.g., EST = UTC-5).
Use the filtered matrix to backtest strategies based on RTH open conditions.
Customize colours and positions to avoid clutter on your chart.
Enjoy trading with enhanced session insights! Feedback and suggestions are welcome.
Also a massive thanks to czoa whose code I've used to generate the RTH levels
Features
Previous Day and Week Levels:
Displays previous day's high, low, and 50% midpoint with customizable colours and labels.
Optionally shows previous week's levels via filter options.
Trading Session Ranges:
Tracks Asia (00:00-07:00), London (07:00-12:45), and New York (13:00-22:00) sessions with configurable time zones.
Visualizes session ranges as boxes, with optional high/low lines and 50% Fibonacci midpoints.
Includes volume and ATR (average true range) stats for each session.
Time-Based Opens:
Plots Midnight Open (00:00) and an additional custom open (default 08:00) with adjustable styles and colours.
RTH Session Levels:
Monitors today’s RTH open, high, low, mid, and yesterday’s RTH open, close, high, low, mid.
Customizable session times (default 09:30-16:00) or use Day Session (08:00-16:00).
Statistical Tables:
Session Stats Table: Shows range, volume, ATR, high, mid, and low for each session.
Correlation Matrix: Displays historical counts of NY session engulfing states relative to London vs. Asia conditions.
Filtered Correlation Matrix: Filters the correlation matrix based on RTH open conditions (e.g., above/below a level or between yesterday’s RTH high/low).
Current Session State Table: Shows the current London vs. Asia engulfing state and whether NY’s RTH open is inside yesterday’s RTH range.
How to Use
Add the indicator to your chart (preferably on an intraday timeframe like 1m, 5m, or 15m for NQ futures), then configure the inputs in the settings panel to tailor it to your needs.
Input Settings
Previous Day Data
Show Previous Day Levels: Toggle visibility of previous day’s high, low, and 50% levels.
Previous Day High/Low/50% Colours: Customize the colours for these lines and labels.
Trading Sessions
New York/London/Asia:
Checkbox: Enable/disable each session.
Text: Rename the session (e.g., "New York" to "NY").
Session Time: Set the session time range (e.g., "1300-2200" for NY).
Colour: Choose the colour for session visuals and text.
Range: Show the session range as a box.
Max/Min: Plot high/low lines for the session.
Show 50% Level: Display the Fibonacci midpoint line.
UTC (+/-): Adjust the timezone offset (e.g., +5 for UTC+5). Use 0 for UTC.
Use Exchange Timezone: Override UTC setting with the chart’s exchange timezone.
Range Area Transparency: Set transparency of session range boxes (0 = opaque, 100 = fully transparent).
Range Outline: Toggle dotted outline for session boxes.
Range Label: Show session name labels above ranges.
Time Based Open
Session: Define the time for Midnight Open (default "0000-0001") and a second open (default "0800-0801").
Line Style: Choose Solid, Dotted, or Dashed for each line.
Colour: Set the colour for each open level.
Show Level: Toggle visibility of each time-based open line.
RTH Session Settings
Session Type: Select "Day Session (RTH)" (08:00-16:00) or "Custom" for user-defined times.
Custom Session: Set custom RTH times (e.g., "0930-1600") if "Custom" is selected.
Today’s RTH Session
Open/Mid/High/Low: Toggle visibility of today’s RTH levels.
Color: Customize the color for each level.
Width: Set line thickness (1-5).
Yesterday’s RTH Session
Open/Close/Mid/High/Low: Toggle visibility of yesterday’s RTH levels.
Colour: Customize the colour for each level.
Width: Set line thickness (1-5).
More Settings
Offset Labels N Bars Right: Move labels right by N bars (default 20).
Multiply Offset for Yesterday’s Labels: Scale the offset for yesterday’s labels (e.g., 1.5 = 50% further).
Label Size: Set size for all labels (Auto, Tiny, Small, Normal, Large, Huge).
Table Settings
Show Session Stats Table: Toggle the stats table.
Stats Table Position/Size/Style: Set position (e.g., "Top Right"), size (e.g., "Small"), and style (Light/Dark).
Show Correlation Matrix: Toggle the full correlation matrix.
Correlation Matrix Position/Size/Style: Configure position, size, and style.
Show Filtered Correlation Matrix: Toggle the filtered matrix.
Filtered Correlation Matrix Position/Size/Style: Configure position, size, and style.
Filter Direction: Choose "Above", "Below", or "Between Yesterday’s RTH High and Low" to filter data.
Filter Level: Select a level (e.g., "Midnight open", "London high") for Above/Below filters.
Show Current Session State Table: Toggle the current state table.
Current Session State Table Position/Size/Style: Configure position (default "Top Center"), size, and style.
Output Description
Chart Overlays:
Lines: Previous day levels, session highs/lows/mids, RTH levels, and time-based opens.
Boxes: Session ranges with customizable colours and transparency.
Labels: Price levels and names next to lines/boxes, offset to the right.
Tables:
Session Stats Table: Columns for Session, Range, Volume, ATR, High, Mid, Low for Asia, London, and NY.
Correlation Matrix: 5x5 grid showing NY engulfing states (Full, Part Up, Part Down, Inside) vs. London vs. Asia states, with total trading days.
Filtered Correlation Matrix: Same as above, but filtered by RTH open conditions (e.g., above Midnight Open).
Current Session State Table: 2x3 grid showing "London vs Asia" (current engulfing state) and "NY Open in Yest RTH Range" (Yes/No).
How to Interpret
Session Ranges: Use the boxes and high/low lines to identify key price zones for each session.
RTH Levels: Compare today’s and yesterday’s RTH levels for potential support/resistance.
Correlation Matrices: Analyse historical patterns (e.g., how often NY fully engulfs London when London engulfs Asia) to inform trading decisions.
Current State: Check the current London vs. Asia relationship and NY open position for real-time context.
Usage Tips
Apply on NQ futures or similar instruments with intraday data.
Adjust session times and timezone to match your market (e.g., EST = UTC-5).
Use the filtered matrix to backtest strategies based on RTH open conditions.
Customize colours and positions to avoid clutter on your chart.
Enjoy trading with enhanced session insights! Feedback and suggestions are welcome.
Also a massive thanks to czoa whose code I've used to generate the RTH levels
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.