OPEN-SOURCE SCRIPT
Atualizado Minimum 30-Day Volatility Screener

Minimum 30-Day Volatility Screener & Risk Matrix
This institutional-grade risk assessment tool is designed to evaluate whether an asset is viable for medium-term (30-day) holding horizons. Rather than relying on simple directional signals, this script analyzes structural market volatility, option premium inflation, and underlying momentum to deliver real-time risk classification and execution style suggestions.
The script runs continuous background diagnostics to separate highly stable trending vehicles from capital-killing congestion zones and high-risk price shocks.
Core Analytical Engines
1. Volatility & Price Shock Diagnostics
The algorithm tracks structural price stability by computing annualized historical volatility against historical variance metrics. Simultaneously, it measures immediate price shocks using an advanced Average True Range (ATR) filter. If an asset drops faster than its normal distribution range (ATR × 1.8), the system flags an imminent price shock risk, protecting you from buying falling knives.
2. Option Premium Inflation Engine (IV Penalty Filter)
To prevent traders from purchasing heavily overpriced options right before a volatility contraction (IV Crush), the script calculates the asset's ATR as a percentage of its current price. If this value exceeds 4.5%, option premiums are flagged as structurally inefficient, allowing you to pivot to pure equity positions.
3. Stagnation & Trend Mechanics
Using mathematical correlation modeling over a 14-period lookback, the script filters out choppy market conditions. Assets exhibiting flat or negative correlations are flagged as low-momentum stagnation zones to preserve opportunity cost. When the structural trend is clear, it relies on an EMA 10/20 crossover sequence to confirm immediate velocity.
How to Use the Risk Matrix Dashboard
The execution matrix is cleanly rendered via a persistent dashboard at the bottom-right of your chart, separating findings into two clear tracks:
Ideal Trading Vehicle: Dynamically recommends the highest-probability instrument structure (e.g., combining 80-Delta LEAPS calls with outright stock equity, reverting to margin equity to bypass options friction, or issuing flat warning indicators when liquidity spreads are poor).
30-Day Hold Horizon Status: Delivers a strict, color-coded diagnostic assessment of structural safety, sorting assets into EXCELLENT 30-DAY VEHICLE, DEAD MONEY TRAP, CAUTION, or CRITICAL PRICE SHOCK risk categories.
----------------------------
Open-Source Disclaimer & Risk Warning
Disclaimer: This script is for educational and informational purposes only. It does not constitute financial, investment, or legal advice. Trading financial instruments involves significant risk of loss and is not suitable for every investor. Past performance is not indicative of future results. The author assumes no liability for any financial losses incurred from using this indicator. Use at your own risk.
Frequently Asked Questions (FAQ)
Why is the 30-Day Annual Volatility showing as 0%?
The underlying code contains a strict structural variance baseline formula: (close - close) / close. If this logic does not match your specific custom backtesting database requirements, you can change the numerator reference to look back one bar (close - close[1]) / close[1] to populate traditional shifting historic variance data.
Can I use this on intraday timeframes (e.g., 5-minute or 1-hour charts)?
While the script will render on any timeframe, the parameters—such as the 45% annual swing risk threshold and the 4.5% ATR premium cap—are optimized for Daily (D) charts. Using lower timeframes will cause compressed ATR readings and may skew the "Ideal Trading Vehicle" recommendations.
Can I move the dashboard to a different corner of my screen?
Yes. Open the Pine Editor, scroll down to the Dashboard Visual Interface section, and change position.bottom_right to your preferred corner (such as position.top_right, position.bottom_left, or position.top_left).
-------------
Release Notes: Version 1.0.0 – Initial Public Deployment
This initial deployment establishes a quantitative foundation for analyzing 30-day structural holding risk and option vehicle efficiency.
🚀 Key Features Deployed
Dynamic Execution Engine: Computes price-to-premium efficiency ratios to recommend 80-Delta calls versus direct equity.
Dual-Layer Momentum Filter: Integrates lookback correlation modeling with EMA crossovers to isolate structural trends.
Volatility Shock Matrix: Calculates real-time ATR price distortion to instantly flag high-risk whipsaw drops.
🔧 Technical Architecture Modifications
Optimized Interface Geometry: Relocated the operational matrix to the bottom-right corner to ensure clear visibility.
Standardized Corporate Protocol: Removed specific broker brand references to deliver a generic, multi-broker compliance profile.
Mathematical Formula Tuning: Refined internal variance baselines to prevent data-feed compilation loops in public environments.
This institutional-grade risk assessment tool is designed to evaluate whether an asset is viable for medium-term (30-day) holding horizons. Rather than relying on simple directional signals, this script analyzes structural market volatility, option premium inflation, and underlying momentum to deliver real-time risk classification and execution style suggestions.
The script runs continuous background diagnostics to separate highly stable trending vehicles from capital-killing congestion zones and high-risk price shocks.
Core Analytical Engines
1. Volatility & Price Shock Diagnostics
The algorithm tracks structural price stability by computing annualized historical volatility against historical variance metrics. Simultaneously, it measures immediate price shocks using an advanced Average True Range (ATR) filter. If an asset drops faster than its normal distribution range (ATR × 1.8), the system flags an imminent price shock risk, protecting you from buying falling knives.
2. Option Premium Inflation Engine (IV Penalty Filter)
To prevent traders from purchasing heavily overpriced options right before a volatility contraction (IV Crush), the script calculates the asset's ATR as a percentage of its current price. If this value exceeds 4.5%, option premiums are flagged as structurally inefficient, allowing you to pivot to pure equity positions.
3. Stagnation & Trend Mechanics
Using mathematical correlation modeling over a 14-period lookback, the script filters out choppy market conditions. Assets exhibiting flat or negative correlations are flagged as low-momentum stagnation zones to preserve opportunity cost. When the structural trend is clear, it relies on an EMA 10/20 crossover sequence to confirm immediate velocity.
How to Use the Risk Matrix Dashboard
The execution matrix is cleanly rendered via a persistent dashboard at the bottom-right of your chart, separating findings into two clear tracks:
Ideal Trading Vehicle: Dynamically recommends the highest-probability instrument structure (e.g., combining 80-Delta LEAPS calls with outright stock equity, reverting to margin equity to bypass options friction, or issuing flat warning indicators when liquidity spreads are poor).
30-Day Hold Horizon Status: Delivers a strict, color-coded diagnostic assessment of structural safety, sorting assets into EXCELLENT 30-DAY VEHICLE, DEAD MONEY TRAP, CAUTION, or CRITICAL PRICE SHOCK risk categories.
----------------------------
Open-Source Disclaimer & Risk Warning
Disclaimer: This script is for educational and informational purposes only. It does not constitute financial, investment, or legal advice. Trading financial instruments involves significant risk of loss and is not suitable for every investor. Past performance is not indicative of future results. The author assumes no liability for any financial losses incurred from using this indicator. Use at your own risk.
Frequently Asked Questions (FAQ)
Why is the 30-Day Annual Volatility showing as 0%?
The underlying code contains a strict structural variance baseline formula: (close - close) / close. If this logic does not match your specific custom backtesting database requirements, you can change the numerator reference to look back one bar (close - close[1]) / close[1] to populate traditional shifting historic variance data.
Can I use this on intraday timeframes (e.g., 5-minute or 1-hour charts)?
While the script will render on any timeframe, the parameters—such as the 45% annual swing risk threshold and the 4.5% ATR premium cap—are optimized for Daily (D) charts. Using lower timeframes will cause compressed ATR readings and may skew the "Ideal Trading Vehicle" recommendations.
Can I move the dashboard to a different corner of my screen?
Yes. Open the Pine Editor, scroll down to the Dashboard Visual Interface section, and change position.bottom_right to your preferred corner (such as position.top_right, position.bottom_left, or position.top_left).
-------------
Release Notes: Version 1.0.0 – Initial Public Deployment
This initial deployment establishes a quantitative foundation for analyzing 30-day structural holding risk and option vehicle efficiency.
🚀 Key Features Deployed
Dynamic Execution Engine: Computes price-to-premium efficiency ratios to recommend 80-Delta calls versus direct equity.
Dual-Layer Momentum Filter: Integrates lookback correlation modeling with EMA crossovers to isolate structural trends.
Volatility Shock Matrix: Calculates real-time ATR price distortion to instantly flag high-risk whipsaw drops.
🔧 Technical Architecture Modifications
Optimized Interface Geometry: Relocated the operational matrix to the bottom-right corner to ensure clear visibility.
Standardized Corporate Protocol: Removed specific broker brand references to deliver a generic, multi-broker compliance profile.
Mathematical Formula Tuning: Refined internal variance baselines to prevent data-feed compilation loops in public environments.
Notas de Lançamento
Removed any named references to commercial platformsNotas de Lançamento
🔄 VERSION UPDATE: New Hold Horizon & Layout ImprovementsWhat's New:
• Added a 7-day hold horizon status to the analysis engine.
• Relocated the result grid layout on the chart for better visual clarity.
Notas de Lançamento
### █ Key Enhancements & Code Optimizations* **Dynamic Market Index Routing:** The calculation engine now automatically scans your chart's prefix and currency metadata. If you are analyzing Indian equities (NSE/BSE), it seamlessly hooks into **`NSE:CNX500`** as the core volatility yardstick. For US or other global equity pools, it cleanly routes metrics directly through **`AMEX:SPY`**.
* **Dual-Layer Momentum & Sensitivity Grading:** Integrated a rolling 14-period **Relative Strength Index (RSI)** to dynamically tag structural Overbought or Oversold boundaries, running alongside a rolling 30-day **Beta Coefficient** calculation engine to map active tracking weights relative to major broad market shifts.
* **Pearson Correlation Overhaul:** Fixed a structural zero-variance calculation loophole (`NaN` runtime errors) by replacing the unstable linear correlation math with an agile rolling 14-bar **Highest/Lowest bandwidth scanner** to securely separate smooth trends from flat, choppy consolidations.
* **Visual Interface Restructuring:** Relocated and scaled the entire dashboard overlay container to **`position.middle_left`** for clean, un-clipped on-screen readability that stays out of the way of recent price bars.
Notas de Lançamento
### █ Script Update Release Notes: Adaptive Setup Metrics & State Tracking* **Universal Setup State Machine:** Added an advanced structural state engine that dynamically detects and monitors macro trend configurations. The dashboard now identifies exactly when a **🟢 BUY READY** or a **🔴 SELL CUTOFF** state fires, and explicitly prints the specific date (`Since YYYY-MM-DD`) that the current state was locked in.
* **Adaptive Beta Fallback Engine:** To prevent execution freezes or runtime compiler loops on unmapped indices, the script features adaptive asset gating. While trend horizons, vehicle recommendations, and RSI matrices run universally on all global assets (including Forex and Crypto), Beta coefficients dynamically query **`NSE:CNX500`** for Indian equities and **`AMEX:SPY`** for US assets. If an unsupported asset class or alternative global region is loaded, the engine isolates the calculation and outputs a clean dashboard exception message (`⚠️ IGNORED: Beta calculation requires US or India asset profile`).
* **High-Contrast Dark Mode Restructuring:** Shifted row layout text parameters across the primary indicators panel from muted tones to bright white (`text_color=color.white`). Adjusted row headers to load custom solid dark charcoal cell backgrounds (`#1E222D`), ensuring high-contrast visibility when overlaying dark trading templates.
* **Unified Column Realignment:** Upgraded layout parameters across every screening matrix field to enforce strict left-alignment boundaries (`text_halign=text.align_left`), organizing values, date strings, and indicators into a scannable grid.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.