Regime Detection for Trading: A Practical Guide (Not Just Theory)
Most regime detection articles are all math and no application. Here is how I actually use Hurst exponent, K-Means clustering, and autoencoders in a live trading system.
If you google "market regime detection" you get a bunch of academic papers with fancy math and zero practical application. I spent months reading these papers trying to figure out how to actually implement regime detection in a real trading system. Here is what I learned.
Why Regimes Matter
Markets cycle between different states. Trending, mean-reverting, volatile, calm. A strategy that works perfectly in a trending market will get chopped up in a range-bound one. If your system can detect which regime it is in, it can adjust its behavior accordingly.
In V7 this is critical. The exit logic uses regime information to decide how long to hold trades. Trending regime (Hurst > 0.55)? Let winners run with 35% giveback. Mean-reverting regime (Hurst < 0.45)? Take profits quick with 25% giveback. That 10% difference in giveback sounds small but it adds up over thousands of trades.
Method 1: Hurst Exponent (S01)
The Hurst exponent measures whether a time series is trending (H > 0.5) or mean-reverting (H < 0.5). H = 0.5 means random walk.
I use the R/S (rescaled range) method with a rolling window of 200 bars on 15-minute data. Its not the most sophisticated estimator but it is robust and computationally cheap.
The key insight I learned the hard way: Hurst exponent is VERY sensitive to the calculation window. Too short and it is noisy. Too long and it is laggy. 200 bars on M15 (about 3 trading days) was the sweet spot for my use case.
Practical notes:
Method 2: K-Means Clustering (S09)
This is my bread and butter regime detector. Cluster the market into 5 states based on:
K-Means with k=5 gives me: Low-Vol Trending, High-Vol Trending, Low-Vol Range, High-Vol Range, and Transitional. The Silhouette score is 0.68 which is solid for financial data (anything above 0.5 is decent).
Why 5 clusters? I tested 3 through 8. Three was too coarse. It could not distinguish between trending and range-bound in high volatility. Eight was overfit. Five gave the best balance between granularity and stability.
Method 3: Autoencoder (S10)
This is the fancy one. Train an autoencoder to learn a compressed representation of market conditions, then use reconstruction error as an anomaly score. High reconstruction error = unusual market conditions = regime change.
Honestly the autoencoder adds less value than I expected. It catches regime transitions about 2-3 bars before K-Means does, which matters for intraday trading but not as much for my M15 timeframe. Still useful as a confirming signal tho.
Architecture: 38 inputs to 16 to 8 to 4 (latent) to 8 to 16 to 38. Trained on 2 years of in-sample data with MSE loss.
How They Work Together
In V7, the three methods vote:
- Hurst exponent gives the trend/reversion classification
- K-Means gives the volatility/momentum regime
- Autoencoder flags anomalous conditions
The exit logic primarily uses Hurst (determines giveback percentage). L1 features include all three regime indicators. S40 Recovery Mode can override in extreme conditions regardless of regime.
The beauty of using multiple methods is robustness. If K-Means says trending but Hurst says mean-reverting, the system is more cautious. Disagreement between detectors = uncertainty = reduce risk.
Implementation Tips
If you are adding regime detection to your own system:
- Start with Hurst. It is simple, interpretable, and gives you the most actionable information (trend vs mean-revert).
- Add K-Means if you need more granularity. It is good for distinguishing volatility regimes which Hurst does not capture.
- Only add autoencoders if you have enough data. You need 2+ years of quality data for the autoencoder to learn meaningful representations.
- Never trade against the regime. If all three detectors say mean-reverting, do not hold trades expecting a trend. This sounds obvious but you would be surprised.
- Re-fit regularly. Market regimes evolve. Your detector should too. I re-fit K-Means quarterly (not the live model, just validate that cluster centroids have not shifted significantly).
Regime detection is one of those things where the concept is simple but the implementation has a hundred gotchas. Take your time getting it right. It affects every other part of your system.
Less Is Usually the Answer
There is a temptation with regime detection to make it overly complicated. More clusters, more features, deeper autoencoders. I fell into that trap. The real question is not "what can I add?" but "what is actually providing signal?" When I honestly evaluated each component, the Hurst exponent, the simplest method, provided the most actionable information. The autoencoder, the fanciest method, added marginal value. Complexity feels like progress. But the map that is simple enough to actually use is worth more than the map that is technically more detailed but impossible to navigate. Know when good enough is the right answer.