OPEN-SOURCE SCRIPT
Обновлено NASDAQ Risk Reference

NASDAQ Position Sizing & Risk Reference Matrix
This script provides a visual reference matrix for risk management when trading NASDAQ futures (NQ / MNQ). It helps traders quickly determine appropriate contract sizes or stop-loss distances based on a predefined dollar risk.
The tool avoids complex chart indicators and focuses entirely on delivering a clean matrix directly within the chart window to streamline order execution.
Features & Calculation Basis
The script calculates values based on the official contract specifications for the NASDAQ-100 Future:
- E-mini (NQ): 1 Point = $20 | 1 Tick = $5
- Micro E-mini (MNQ): 1 Point = $2 | 1 Tick = $0.50
Display Modes (Layouts)
Three distinct table layouts are available and can be selected via the settings menu:
1. By Contracts: Displays the maximum allowed stop-loss distance in points or ticks for a sequential number of contracts (quantity 1 to n) to strictly maintain the selected dollar risk.
2. By SL Distance: Displays the maximum number of contracts (rounded down to whole numbers) that can be traded for specific stop-loss distances, using a customizable start value and step increment.
3. Both (Combined View): Displays both tables side-by-side with a clean visual separator for an optimal layout.
Input Parameters
- Risk (USD): The maximum risk per trade in US Dollars (e.g., $200).
- Unit: Switchable between Ticks and Points for all distance metrics.
- Table Rows: Determines the length of the table (number of contract levels or SL steps).
- SL Start & Step: Defines the mathematical grid for the "By SL Distance" mode.
- Table Design: Fully adjustable positioning (e.g., top-right, bottom-left), background transparency, text color, and text size.
Technical Note
The table calculates exclusively on the historical data of the latest available bar (barstate.islast) to optimize chart performance. Contract sizes in distance mode are rounded down using math.floor, as fractional contracts cannot be executed in live trading.
This script provides a visual reference matrix for risk management when trading NASDAQ futures (NQ / MNQ). It helps traders quickly determine appropriate contract sizes or stop-loss distances based on a predefined dollar risk.
The tool avoids complex chart indicators and focuses entirely on delivering a clean matrix directly within the chart window to streamline order execution.
Features & Calculation Basis
The script calculates values based on the official contract specifications for the NASDAQ-100 Future:
- E-mini (NQ): 1 Point = $20 | 1 Tick = $5
- Micro E-mini (MNQ): 1 Point = $2 | 1 Tick = $0.50
Display Modes (Layouts)
Three distinct table layouts are available and can be selected via the settings menu:
1. By Contracts: Displays the maximum allowed stop-loss distance in points or ticks for a sequential number of contracts (quantity 1 to n) to strictly maintain the selected dollar risk.
2. By SL Distance: Displays the maximum number of contracts (rounded down to whole numbers) that can be traded for specific stop-loss distances, using a customizable start value and step increment.
3. Both (Combined View): Displays both tables side-by-side with a clean visual separator for an optimal layout.
Input Parameters
- Risk (USD): The maximum risk per trade in US Dollars (e.g., $200).
- Unit: Switchable between Ticks and Points for all distance metrics.
- Table Rows: Determines the length of the table (number of contract levels or SL steps).
- SL Start & Step: Defines the mathematical grid for the "By SL Distance" mode.
- Table Design: Fully adjustable positioning (e.g., top-right, bottom-left), background transparency, text color, and text size.
Technical Note
The table calculates exclusively on the historical data of the latest available bar (barstate.islast) to optimize chart performance. Contract sizes in distance mode are rounded down using math.floor, as fractional contracts cannot be executed in live trading.
Информация о релизе
Changelog (v2.1)- Added a compact Risk USD display directly in the top-left cell of the table to show the currently selected account risk at a glance.
Информация о релизе
NASDAQ Position Sizing & Risk Reference MatrixThis script provides a visual reference matrix for risk management when trading NASDAQ futures (NQ / MNQ). It helps traders quickly determine appropriate contract sizes or stop-loss distances based on a predefined dollar risk.
The tool avoids complex chart indicators and focuses entirely on delivering a clean matrix directly within the chart window to streamline order execution.
Update: Volatility-Based SL Calculation & Smart Filtering
The indicator has been significantly expanded and officially renamed to "NASDAQ Risk Reference by Swings". Alongside the static risk calculation, the tool now optionally analyzes the current market structure to derive dynamic stop-loss reference values and adapt the table interactively. To maintain a clean and minimalist default view, all new analytical features are disabled out-of-the-box.
New Features & Enhancements:
Historical Swing SL: The script calculates a statistical reference stop-loss based on the point difference of the last n alternating swings (high-to-low / low-to-high). The percentage of the average swing used as a reference is fully customizable.
Volatility Safety Buffer: An optional safety mechanism that compares the volatility of recent swings against a longer historical baseline. If the current volatility exceeds a defined threshold, the SL reference is proportionally scaled up and highlighted in the table with a warning symbol (⚠️) and orange text.
Chart Visualization: The exact point distances of the analyzed swings can optionally be displayed as text labels directly at the corresponding pivot points on the chart, providing full transparency of the underlying calculations.
Smart Highlighting & Viability Check: The table automatically identifies the rows closest to the calculated SL reference, highlighting the respective cells and column headers (Mini / Micro). A built-in Viability Check ensures that no contract sizes are highlighted if the required SL would exceed the defined risk limit for a single contract.
Smart Table Filtering: To save chart space, the matrix can be compressed to only show the most relevant rows (the best matches for Minis and Micros), hiding irrelevant intermediate tiers. Adjacent rows (+1 / -1) can be optionally displayed for better orientation.
UI & Quality of Life: All input fields in the settings menu are now fully documented with bilingual tooltips (DE | EN).
Информация о релизе
25.05.26 Changelog (v4.8):Array Sync Optimization: Cleaned up the historical swing array initialization. This prevents asynchronous calculation discrepancies (such as the 38.9 vs. 61.6 point difference) caused by Pine Script's memory cache when toggling settings or updating code. Calculations are now strictly synchronized from the first to the last chart bar.
Информация о релизе
Changelog (v4.9):Risk Row: Added option to display candle statistics (Avg and Max).
Информация о релизе
Changelog (v4.9.2):Risk Row: Added option to display candle statistics (Cdl Avg and Max), left-aligned to ensure stable display.
Информация о релизе
Update v2: Dynamic SL Calculation & Smart FilteringThe indicator has been significantly expanded and officially renamed to "NASDAQ Risk Reference by Swings v2". In addition to the static risk matrix, the tool now optionally analyzes the current market structure to display dynamic stop-loss reference values directly on the chart and within the table.
New Features & Enhancements:
Historical Swing SL & Volatility Buffer: Calculates a statistical reference SL based on the last n swings. An optional volatility buffer detects extreme market breakouts and automatically adjusts the reference value (indicated by a ⚠️ warning symbol).
Dynamic Last Swing SL: Displays the SL of the last valid swing. In "Auto (iFVG Trend)" mode, this SL dynamically synchronizes with the directional bias of the active market structure.
Smart iFVG Detection: Identifies Inverse Fair Value Gaps (iFVG) using an intelligent "3-Pivot Memory" to filter out irrelevant market noise. A "Live Ghost Line" visualizes developing reversals before candle close. Built-in Overrun Protection prevents flickering of already triggered levels.
Smart Table Filtering: The table now automatically identifies and highlights the optimal contract sizes for the calculated SL. To keep the chart uncluttered, the matrix can be compressed to display only the most relevant rows.
UI & Quality of Life: Completely overhauled English user interface featuring bilingual tooltips (EN/DE). Optional live candle statistics have been integrated directly into the table header.
Информация о релизе
June 26Release Notes
Changelog (v2.1.1):
Fixed Runtime Error: Resolved a critical crash ("Index 0 is out of bounds, array size is 0") that occurred when the smart table filtering was active. If no optimal contract sizes were found, Pine Script's loop logic forced an invalid iteration (0 to -1). This is now blocked by an explicit array size check (array.size() > 0) prior to execution.
Input Validation: Added a strict minval=1 constraint to the swing_count (Swings to Avg) parameter to prevent mathematical division-by-zero errors and subsequent crashes if the value was manually set to zero in the settings menu.
Скрипт с открытым кодом
В истинном духе TradingView, создатель этого скрипта сделал его открытым исходным кодом, чтобы трейдеры могли проверить и убедиться в его функциональности. Браво автору! Вы можете использовать его бесплатно, но помните, что перепубликация кода подчиняется нашим Правилам поведения.
Отказ от ответственности
Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.
Скрипт с открытым кодом
В истинном духе TradingView, создатель этого скрипта сделал его открытым исходным кодом, чтобы трейдеры могли проверить и убедиться в его функциональности. Браво автору! Вы можете использовать его бесплатно, но помните, что перепубликация кода подчиняется нашим Правилам поведения.
Отказ от ответственности
Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.