OPEN-SOURCE SCRIPT
Risk Analysis [OmegaTools]

Risk Analysis [OmegaTools]
Overview
Risk Analysis [OmegaTools] is a professional-grade, overlay risk dashboard designed for active traders and quantitative analysts who need a structured, real-time view of market conditions directly on their chart. Rather than cluttering the chart with multiple sub-pane indicators, this tool consolidates eight statistically grounded risk and market-structure metrics into a single, clean, repositionable table — giving you an immediate read on directionality, volatility, momentum regime, and price positioning at a glance.
The indicator is fully dollar-denominated via syminfo.pointvalue, making it natively compatible with futures contracts (NQ, ES, GC, CL, 6E, and others), where tick-scaled dollar values are essential for meaningful risk sizing and trade management.
Metrics Explained
Directionality — ADR$
The Average Directional Range captures the one-sided, committed portion of each bar's movement — the distance price traveled in a single direction — as opposed to the full high-low span. It blends a short-term RMA (11) with a medium-term SMA (34) to smooth noise while remaining responsive to shifts in directional energy.
Pine Script®
Expressed in dollar terms, ADR gives you a practical measure of how much price has been committing to a direction per bar, which directly informs target placement and profit expectation calibration.
Volatility — ATR$
The Average True Range measures the full extent of bar-to-bar price expansion, capturing both directional and indecisive (choppy) volatility. The same dual-smoothing structure (RMA 11 averaged with SMA 34) is applied for consistency with the ADR calculation.
Pine Script®
Expressed in dollars, ATR serves as the baseline volatility reference for stop-loss sizing, risk-reward calibration, and position sizing models.
Directionality Relative — X multiplier
This metric contextualizes the current ADR/ATR ratio against its own 50-bar rolling average, expressing the result as a multiplier.
Pine Script®
A reading of 1.0X means directional intensity is at its historical norm. Values above 1.0X indicate the market is more directional than its recent baseline, which is favorable for trend-following approaches. Values below 1.0X signal a contraction in directionality, suggesting a shift toward mean-reversion or consolidation conditions.
Distance from High — $
The dollar distance between the current close and the 11-bar swing high. This metric directly quantifies how much room price has traveled away from a recent structural peak, which is critical for assessing short-side risk exposure, trailing stop management, and mean-reversion entry evaluation.
Pine Script®
Low values indicate price is pinned near the top of the recent range. High values indicate extended downside displacement from the swing high.
Distance from Low — $
The symmetric complement — the dollar distance between the current close and the 11-bar swing low. High values indicate price has stretched far above a recent structural base.
Pine Script®
This pair of metrics together defines the current intra-range positioning of price, which is indispensable for both breakout and mean-reversion setups.
ADF — Augmented Dickey-Fuller Proxy
The ADF metric is a statistical proxy for the Augmented Dickey-Fuller test, a classic econometric test for stationarity (mean-reversion) versus unit-root behavior (trending). The 100-bar Pearson correlation between price changes and lagged price levels is used as the core signal, then scaled and shifted for readability.
Pine Script®
A negative correlation between price changes and price levels implies mean-reverting dynamics. A positive correlation implies trend-persistence. Values above 0 indicate a strong trending regime. Values near 0 indicate a transitional or mixed regime. Values below 0 indicate a mean-reverting regime where price consistently reverts from extremes. This is particularly valuable for regime-conditional strategy selection.
Relative Volume — RelVolume X
Relative Volume compares short-term volume activity against medium-term baseline activity, expressed as a multiplier.
Pine Script®
Values above 1.0X indicate current volume is elevated relative to the recent norm, signaling heightened participation. Values near 1.0X indicate volume is in line with baseline. Values below 1.0X indicate suppressed volume and low conviction. This metric is essential for filtering signal quality — high-conviction moves require volume confirmation, and this ratio makes that assessment immediate and quantitative.
Z-Score
The Z-Score measures how many standard deviations the current price is displaced from its 21-bar rolling mean. It is one of the most direct statistical measures of mean-reversion opportunity.
Pine Script®
A Z-Score above +2 indicates price is significantly extended to the upside with elevated reversion risk. A Z-Score below −2 indicates price is significantly extended to the downside. A Z-Score near 0 indicates price is trading near its statistical center of gravity. Combined with the ADF and Relative Volume, the Z-Score completes a full statistical picture of the current market regime and opportunity type.
How to Use This Indicator
Trend-Following Context
When ADF is above 0, Directionality Relative is above 1.0X, and Relative Volume is above 1.0X, the market is showing statistically robust trending behavior with above-average participation. In this context, use ATR$ for stop-loss placement and ADR$ for realistic target sizing. Use Distance from High and Distance from Low to assess whether a pullback entry is available or whether price has already extended beyond a reasonable entry point.
Mean-Reversion Context
When ADF is below 0, Z-Score is above ±1.5, and Directionality Relative is below 1.0X, the market structure favors mean-reversion setups. Distance from High and Low identifies the magnitude of the current displacement from structure. Relative Volume below 1.0X in this context supports a low-conviction, fading approach.
Position Sizing
All dollar-denominated metrics — ADR$, ATR$, Distance from High$, Distance from Low$ — are scaled by syminfo.pointvalue, making them directly usable for dollar-based risk models. For example: if ATR$ reads 300$, a 1-ATR stop on a standard NQ contract represents $300 of risk per contract with no manual conversion required.
Inputs
Table Location — Default: Top Center. Repositions the dashboard anywhere on the chart. Available positions: Bottom Right, Bottom Center, Bottom Left, Middle Right, Middle Center, Middle Left, Top Right, Top Center, Top Left.
Compatibility
Recommended for futures markets where syminfo.pointvalue is meaningful (NQ, ES, CL, GC, 6E, and others). Compatible with all asset classes and all timeframes. Renders as an overlay table directly on the price chart with no sub-pane required. The table uses chart.fg_color throughout for full light and dark theme compatibility. All calculations run on the current symbol and timeframe with no secondary data requests, keeping the indicator lightweight and fast.
Notes
This indicator is published open source. Study, adapt, and build on it freely.
© OmegaTools — Professional quantitative tools for serious traders.
Overview
Risk Analysis [OmegaTools] is a professional-grade, overlay risk dashboard designed for active traders and quantitative analysts who need a structured, real-time view of market conditions directly on their chart. Rather than cluttering the chart with multiple sub-pane indicators, this tool consolidates eight statistically grounded risk and market-structure metrics into a single, clean, repositionable table — giving you an immediate read on directionality, volatility, momentum regime, and price positioning at a glance.
The indicator is fully dollar-denominated via syminfo.pointvalue, making it natively compatible with futures contracts (NQ, ES, GC, CL, 6E, and others), where tick-scaled dollar values are essential for meaningful risk sizing and trade management.
Metrics Explained
Directionality — ADR$
The Average Directional Range captures the one-sided, committed portion of each bar's movement — the distance price traveled in a single direction — as opposed to the full high-low span. It blends a short-term RMA (11) with a medium-term SMA (34) to smooth noise while remaining responsive to shifts in directional energy.
dr = math.max(high - close, close - open)
adr = math.avg(ta.rma(dr, 11), ta.sma(dr, 34)) * syminfo.pointvalue
Expressed in dollar terms, ADR gives you a practical measure of how much price has been committing to a direction per bar, which directly informs target placement and profit expectation calibration.
Volatility — ATR$
The Average True Range measures the full extent of bar-to-bar price expansion, capturing both directional and indecisive (choppy) volatility. The same dual-smoothing structure (RMA 11 averaged with SMA 34) is applied for consistency with the ADR calculation.
tr = high - low
atr = math.avg(ta.rma(tr, 11), ta.sma(tr, 34)) * syminfo.pointvalue
Expressed in dollars, ATR serves as the baseline volatility reference for stop-loss sizing, risk-reward calibration, and position sizing models.
Directionality Relative — X multiplier
This metric contextualizes the current ADR/ATR ratio against its own 50-bar rolling average, expressing the result as a multiplier.
directionality = adr / atr * 100
directionalityrelative = directionality[1] / ta.sma(directionality[1], 50)
A reading of 1.0X means directional intensity is at its historical norm. Values above 1.0X indicate the market is more directional than its recent baseline, which is favorable for trend-following approaches. Values below 1.0X signal a contraction in directionality, suggesting a shift toward mean-reversion or consolidation conditions.
Distance from High — $
The dollar distance between the current close and the 11-bar swing high. This metric directly quantifies how much room price has traveled away from a recent structural peak, which is critical for assessing short-side risk exposure, trailing stop management, and mean-reversion entry evaluation.
distfromh = (ta.highest(high, 11) - close) * syminfo.pointvalue
Low values indicate price is pinned near the top of the recent range. High values indicate extended downside displacement from the swing high.
Distance from Low — $
The symmetric complement — the dollar distance between the current close and the 11-bar swing low. High values indicate price has stretched far above a recent structural base.
distfroml = (close - ta.lowest(low, 11)) * syminfo.pointvalue
This pair of metrics together defines the current intra-range positioning of price, which is indispensable for both breakout and mean-reversion setups.
ADF — Augmented Dickey-Fuller Proxy
The ADF metric is a statistical proxy for the Augmented Dickey-Fuller test, a classic econometric test for stationarity (mean-reversion) versus unit-root behavior (trending). The 100-bar Pearson correlation between price changes and lagged price levels is used as the core signal, then scaled and shifted for readability.
adf = ta.correlation(close - close[1], close[1], 100) * 10 + 0.5
A negative correlation between price changes and price levels implies mean-reverting dynamics. A positive correlation implies trend-persistence. Values above 0 indicate a strong trending regime. Values near 0 indicate a transitional or mixed regime. Values below 0 indicate a mean-reverting regime where price consistently reverts from extremes. This is particularly valuable for regime-conditional strategy selection.
Relative Volume — RelVolume X
Relative Volume compares short-term volume activity against medium-term baseline activity, expressed as a multiplier.
relvol = ta.sma(volume, 5) / ta.sma(volume, 21)
Values above 1.0X indicate current volume is elevated relative to the recent norm, signaling heightened participation. Values near 1.0X indicate volume is in line with baseline. Values below 1.0X indicate suppressed volume and low conviction. This metric is essential for filtering signal quality — high-conviction moves require volume confirmation, and this ratio makes that assessment immediate and quantitative.
Z-Score
The Z-Score measures how many standard deviations the current price is displaced from its 21-bar rolling mean. It is one of the most direct statistical measures of mean-reversion opportunity.
zscore = (close - ta.sma(close, 21)) / ta.stdev(close, 21)
A Z-Score above +2 indicates price is significantly extended to the upside with elevated reversion risk. A Z-Score below −2 indicates price is significantly extended to the downside. A Z-Score near 0 indicates price is trading near its statistical center of gravity. Combined with the ADF and Relative Volume, the Z-Score completes a full statistical picture of the current market regime and opportunity type.
How to Use This Indicator
Trend-Following Context
When ADF is above 0, Directionality Relative is above 1.0X, and Relative Volume is above 1.0X, the market is showing statistically robust trending behavior with above-average participation. In this context, use ATR$ for stop-loss placement and ADR$ for realistic target sizing. Use Distance from High and Distance from Low to assess whether a pullback entry is available or whether price has already extended beyond a reasonable entry point.
Mean-Reversion Context
When ADF is below 0, Z-Score is above ±1.5, and Directionality Relative is below 1.0X, the market structure favors mean-reversion setups. Distance from High and Low identifies the magnitude of the current displacement from structure. Relative Volume below 1.0X in this context supports a low-conviction, fading approach.
Position Sizing
All dollar-denominated metrics — ADR$, ATR$, Distance from High$, Distance from Low$ — are scaled by syminfo.pointvalue, making them directly usable for dollar-based risk models. For example: if ATR$ reads 300$, a 1-ATR stop on a standard NQ contract represents $300 of risk per contract with no manual conversion required.
Inputs
Table Location — Default: Top Center. Repositions the dashboard anywhere on the chart. Available positions: Bottom Right, Bottom Center, Bottom Left, Middle Right, Middle Center, Middle Left, Top Right, Top Center, Top Left.
Compatibility
Recommended for futures markets where syminfo.pointvalue is meaningful (NQ, ES, CL, GC, 6E, and others). Compatible with all asset classes and all timeframes. Renders as an overlay table directly on the price chart with no sub-pane required. The table uses chart.fg_color throughout for full light and dark theme compatibility. All calculations run on the current symbol and timeframe with no secondary data requests, keeping the indicator lightweight and fast.
Notes
This indicator is published open source. Study, adapt, and build on it freely.
© OmegaTools — Professional quantitative tools for serious traders.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.