OPEN-SOURCE SCRIPT

Market Regime Matrix [Alpha Extract]

589
A sophisticated market regime classification system that combines multiple technical analysis components into an intelligent scoring framework to identify and track dominant market conditions. Utilizing advanced ADX-based trend detection, EMA directional analysis, volatility assessment, and crash protection protocols, the Market Regime Matrix delivers institutional-grade regime classification with BULL, BEAR, and CHOP states. The system features intelligent scoring with smoothing algorithms, duration filters for stability, and structure-based conviction adjustments to provide traders with clear, actionable market context.

🔶 Multi-Component Regime Engine Integrates five core analytical components: ADX trend strength detection, EMA-200 directional bias, ROC momentum analysis, Bollinger Band volatility measurement, and zig-zag structure verification. Each component contributes to a sophisticated scoring system that evaluates market conditions across multiple dimensions, ensuring comprehensive regime assessment with institutional precision.

Pine Script®
// Gate Keeper: ADX determines market type is_trending = adx_value > adx_trend_threshold is_ranging = adx_value <= adx_trend_threshold is_maximum_chop = adx_value <= adx_chop_threshold // BULL CONDITIONS with Structure Veto if price_above_ema and di_bullish if use_structure_filter and isBullStructure raw_bullScore := 5.0 // MAXIMUM CONVICTION: Strong signals + Bull structure else if use_structure_filter and not isBullStructure raw_bullScore := 3.0 // REDUCED: Strong signals but broken structure


🔶 Intelligent Scoring System Employs a dynamic 0-5 scale scoring mechanism for each regime type (BULL/BEAR/CHOP) with adaptive conviction levels. The system automatically adjusts scores based on signal alignment, market structure confirmation, and volatility conditions. Features decision margin requirements to prevent false regime changes and includes maximum conviction thresholds for high-probability setups.

🔶 Advanced Structure Filter Implements zig-zag based market structure analysis using configurable deviation thresholds to identify significant pivot points. The system tracks Higher Highs/Higher Lows (HH/HL) for bullish structure and Lower Lows/Lower Highs (LL/LH) for bearish structure, applying structure veto logic that reduces conviction when price action contradicts the underlying trend framework.

Pine Script®
// Define Market Structure (Bull = HH/HL, Bear = LL/LH) isBullStructure = not na(last_significant_high) and not na(prev_significant_high) and not na(last_significant_low) and not na(prev_significant_low) and last_significant_high > prev_significant_high and last_significant_low > prev_significant_low isBearStructure = not na(last_significant_high) and not na(prev_significant_high) and not na(last_significant_low) and not na(prev_significant_low) and last_significant_low < prev_significant_low and last_significant_high < prev_significant_high


🔶 Superior Engine Components Features dual-layer regime stabilization through score smoothing and duration filtering. The score smoothing component reduces noise by averaging raw scores over configurable periods, while the duration filter requires minimum regime persistence before confirming changes. This eliminates whipsaws and ensures regime transitions represent genuine market shifts rather than temporary fluctuations.

🔶 Crash Detection & Active Penalties Incorporates sophisticated crash detection using Rate of Change (ROC) analysis with severity classification. When crash conditions are detected, the system applies active penalties (-5.0) to BULL and CHOP scores while boosting BEAR conviction based on crash severity. This ensures immediate regime response to major market dislocations and drawdown events.

Pine Script®
// === CRASH OVERRIDE (Active Penalties) === is_crash = roc_value < crash_threshold if is_crash // Calculate crash severity crash_severity = math.abs(roc_value / crash_threshold) crash_bonus = 4.0 + (crash_severity - 1.0) * 2.0 // ACTIVE PENALTIES: Force bear dominance raw_bearScore := math.max(raw_bearScore, crash_bonus) raw_bullScore := -5.0 // ACTIVE PENALTY raw_chopScore := -5.0 // ACTIVE PENALTY


❓How It Works

🔶 ADX-Based Market Classification The Market Regime Matrix uses ADX (Average Directional Index) as the primary gatekeeper to distinguish between trending and ranging market conditions. When ADX exceeds the trend threshold, the system activates BULL/BEAR regime logic using DI+/DI- crossovers and EMA positioning. When ADX falls below the ranging threshold, CHOP regime logic takes precedence, with maximum conviction assigned during ultra-low ADX periods.

istantanea

🔶 Dynamic Conviction Scaling Each regime receives conviction ratings from UNCERTAIN to MAXIMUM based on signal alignment and score magnitude. MAXIMUM conviction (5.0 score) requires perfect signal alignment plus favorable market structure. The system progressively reduces conviction when signals conflict or structure breaks, ensuring traders understand the reliability of each regime classification.

🔶 Regime Transition Management Implements decision margin requirements where new regimes must exceed existing regimes by configurable thresholds before transitions occur. Combined with duration filtering, this prevents premature regime changes and maintains stability during consolidation periods. The system tracks both raw regime signals and final regime output for complete transparency.

🔶 Visual Regime Mapping Provides comprehensive visual feedback through colored candle overlays, background regime highlighting, and real-time information tables. The system displays regime history, conviction levels, structure status, and key metrics in an organized dashboard format. Regime changes trigger immediate visual alerts with detailed transition information.

istantanea

🔶 Performance Optimization Features efficient array management for zig-zag calculations, smart variable updating to prevent recomputation, and configurable debug modes for strategy development. The system maintains optimal performance across all timeframes while providing institutional-grade analytical depth.

Why Choose Market Regime Matrix [Alpha Extract]?

The Market Regime Matrix represents the evolution of market regime analysis, combining traditional technical indicators with modern algorithmic decision-making frameworks. By integrating multiple analytical dimensions with intelligent scoring, structure verification, and crash protection, it provides traders with institutional-quality market context that adapts to changing conditions. The sophisticated filtering system eliminates noise while preserving responsiveness, making it an essential tool for traders seeking to align their strategies with dominant market regimes and avoid adverse market environments.

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.