Classify market conditions in real-time using statistical indicators. Is it trending? Mean-reverting? Volatile? Generate synthetic markets or paste real prices and watch the detector work.
The detector classifies market conditions using four statistical indicators computed on a rolling window:
Trend Strength — Linear regression slope of log-prices over the lookback window, normalized by volatility. Strong positive = uptrend, strong negative = downtrend.
Volatility — Annualized standard deviation of returns. High volatility
regimes need different strategies than calm ones. Measured as σ × √252.
Hurst Exponent — Approximated via rescaled range (R/S) analysis.
H > 0.5 = trending (momentum works),
H < 0.5 = mean-reverting (fade moves),
H ≈ 0.5 = random walk (nothing works reliably).
Momentum — Rate of change over the lookback period. Confirms trend direction and strength. Divergence between momentum and trend can signal regime shifts.
The regime is classified by combining these signals: trending markets have strong directional slope + high Hurst; mean-reverting markets have low Hurst + weak trend; volatile markets have high σ regardless of direction; calm markets are low σ + no strong trend.
Why it matters: Most trading strategies only work in specific regimes. Momentum strategies print money in trends and bleed in chop. Mean reversion strategies are the opposite. Knowing which regime you're in is half the battle.