Back to Library

Adaptive Centroid Regime Classifier

AI / ML

An online vector-quantization regime detector that classifies the market into Trend Up, Trend Down, or Range using three adaptive centroids with dynamic labeling, confidence scoring, and anti-whipsaw hysteresis.

How It Works

The indicator maintains three centroids in a 3D feature space: deviation-from-mean momentum (normalized by ATR), relative volatility (z-scored ATR), and true ADX trend strength. On each bar, features are standardized via rolling z-scores, then the bar is assigned to the nearest centroid using weighted Manhattan distance. The winning centroid is updated via exponential moving average (online learning). Critically, regime labels are assigned dynamically — the centroid with the highest momentum is labeled Bullish, the lowest is Bearish, and the remaining is Range — so labels always follow the model state, not hardcoded indices. A persistence filter prevents regime flips unless the new regime holds for N consecutive bars, reducing false signals in choppy conditions. A confidence score (distance gap between best and second-best cluster) distinguishes high-conviction from ambiguous regimes.