PROTECTED SOURCE SCRIPT
QUANTA - LAB HMM REGIME DETECTION

Two-state Hidden Markov Model for market regime detection based on Hamilton (1989) Markov-Switching framework.
Methodology:
Full Baum-Welch EM algorithm in log-space for numerical stability
Real-time Hamilton filtering (no lookahead) for trading use
Kim smoothing for historical analysis
Multiple random restarts to avoid local optima
Regime Classification:
Mean-based: R1 = Bearish (lower μ), R2 = Bullish (higher μ)
Volatility-based: R1 = Calm (lower σ), R2 = Turbulent (higher σ)
Key Features:
TRADING vs ANALYSIS mode (filtered vs smoothed probabilities)
Gaussian assumption diagnostics (kurtosis, skewness, outliers)
Data Quality Score (0-100)
Regime Certainty Index (RCI)
Mean separation t-statistic
Expected regime duration and ergodic probabilities
Degenerate model detection
Dashboard Includes:
Filtered probabilities (real-time, safe for trading)
Emission parameters (μ₁, μ₂, σ₁, σ₂)
Transition matrix (p₁₁, p₂₂)
Model fit metrics (LogL, AIC, BIC)
Critical Warnings:
Smoothed ≠ Real-time (smoothed uses future info)
Gaussian assumption: fat tails not captured
K=2 regimes only — may oversimplify dynamics
NOT for high-frequency (minimum 1H timeframe)
Validate with Python hmmlearn / R / MATLAB
References: Hamilton (1989) — Econometrica
Methodology:
Full Baum-Welch EM algorithm in log-space for numerical stability
Real-time Hamilton filtering (no lookahead) for trading use
Kim smoothing for historical analysis
Multiple random restarts to avoid local optima
Regime Classification:
Mean-based: R1 = Bearish (lower μ), R2 = Bullish (higher μ)
Volatility-based: R1 = Calm (lower σ), R2 = Turbulent (higher σ)
Key Features:
TRADING vs ANALYSIS mode (filtered vs smoothed probabilities)
Gaussian assumption diagnostics (kurtosis, skewness, outliers)
Data Quality Score (0-100)
Regime Certainty Index (RCI)
Mean separation t-statistic
Expected regime duration and ergodic probabilities
Degenerate model detection
Dashboard Includes:
Filtered probabilities (real-time, safe for trading)
Emission parameters (μ₁, μ₂, σ₁, σ₂)
Transition matrix (p₁₁, p₂₂)
Model fit metrics (LogL, AIC, BIC)
Critical Warnings:
Smoothed ≠ Real-time (smoothed uses future info)
Gaussian assumption: fat tails not captured
K=2 regimes only — may oversimplify dynamics
NOT for high-frequency (minimum 1H timeframe)
Validate with Python hmmlearn / R / MATLAB
References: Hamilton (1989) — Econometrica
สคริปต์ที่ได้รับการป้องกัน
สคริปต์นี้ถูกเผยแพร่เป็นแบบ closed-source อย่างไรก็ตาม คุณสามารถใช้ได้อย่างอิสระและไม่มีข้อจำกัดใดๆ – เรียนรู้เพิ่มเติมได้ที่นี่
Institutional-grade diagnostics: GARCH, HMM Regimes, Cointegration, Microstructure, Fractal Analysis | Research only
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์ที่ได้รับการป้องกัน
สคริปต์นี้ถูกเผยแพร่เป็นแบบ closed-source อย่างไรก็ตาม คุณสามารถใช้ได้อย่างอิสระและไม่มีข้อจำกัดใดๆ – เรียนรู้เพิ่มเติมได้ที่นี่
Institutional-grade diagnostics: GARCH, HMM Regimes, Cointegration, Microstructure, Fractal Analysis | Research only
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน