# HMM Predictor - Hidden Markov Model Market Regime Detection and State Analysis

**Last Updated**: 2026-03-17
**Version**: 1.0.0

## How It Works

### Open the HMM Predictor

Navigate to the HMM Predictor page from the sidebar. The interface provides controls for configuring Hidden Markov Model analysis including asset selection, date parameters, and model training settings.

### Select Asset and Analysis Date

Choose the target symbol using the asset selector and set the analysis date. The HMM model will be trained on historical data leading up to this date and produce a regime classification for the current market state.

### Configure Timeframe and Training Length

Select the data timeframe (daily, hourly, etc.) and set the training data length. Longer training windows (500+ bars) produce more stable regime estimates, while shorter windows (100-200 bars) are more responsive to recent regime shifts.

### Set the Number of Hidden States

Define how many hidden regimes the model should detect, typically 2-4 states. Two states capture bull/bear cycles. Three states add a neutral/ranging phase. Four states can distinguish low-volatility trending from high-volatility trending environments.

### Execute the HMM Analysis

Click the Run button to train the Hidden Markov Model on the configured dataset. The algorithm applies the Baum-Welch (Expectation-Maximization) algorithm to estimate model parameters and the Viterbi algorithm to decode the most likely state sequence.

### Review Regime Classification Results

Examine the output including: the current detected regime, state probability distribution, transition probability matrix showing likelihood of switching between regimes, and the historical state sequence overlaid on the price chart.

### Apply Regime Insights to Strategy Selection

Use the detected regime to inform your strategy choice. Trending regimes favor momentum and breakout strategies. Ranging regimes suit mean-reversion approaches. High-volatility regimes call for wider stop-losses and reduced position sizes. Feed regime data into other platform modules for regime-adaptive trading.

> The HMM Predictor uses Hidden Markov Models, a statistical framework from sequential data analysis, to classify market conditions into distinct regimes based on observable price and volume patterns.

## Tips & Best Practices

- Start with 3 hidden states (bullish, bearish, neutral) as your default configuration. This captures the most common market dynamics without overcomplicating the model. Only add a 4th state if you specifically need to distinguish volatility regimes.

- Pay close attention to the transition probability matrix. If the probability of staying in the current regime is above 90%, the regime is stable. If transition probabilities to other states are rising above 15-20%, a regime shift may be imminent.

- Use daily timeframe data with at least 500 bars of training history for the most statistically robust regime detection. Shorter training windows or intraday data can produce noisier state classifications.

## Frequently Asked Questions

### What is a Hidden Markov Model and why is it used for markets?

A Hidden Markov Model (HMM) is a statistical model that assumes an observed sequence (price returns, volatility) is generated by an underlying process that transitions between a finite set of hidden states. In finance, these hidden states correspond to market regimes like trending, ranging, or volatile. HMMs are particularly suited for markets because they capture the reality that market behavior shifts between distinct modes that are not directly observable but can be inferred from price data.

### What do the transition probabilities tell me?

The transition probability matrix shows the likelihood of moving from one regime to another in the next time step. For example, if the probability of staying in Regime 0 (trending) is 0.95, the market has a 95% chance of remaining in the trending state. A transition probability of 0.03 from trending to ranging means only a 3% chance of regime change per bar. Watch for rising transition probabilities as early warning signals of regime shifts.

### How should I interpret the state probability distribution?

The state probability distribution shows the model's confidence that the market is currently in each possible regime. If the distribution shows 85% Regime 1, 10% Regime 2, and 5% Regime 0, the model is highly confident the market is in Regime 1. When probabilities are more evenly distributed (e.g., 45%/35%/20%), the market may be in transition between regimes and signals should be treated with more caution.

### Can I change the number of hidden states after seeing results?

Yes, you can re-run the analysis with a different number of states. Comparing results across 2-state, 3-state, and 4-state models is a common practice to find the configuration that best explains your asset's behavior. Generally, simpler models (fewer states) are more robust, while more states capture finer distinctions but may overfit on limited data.

## Important Notes

> HMM regime detection is a statistical classification tool based on historical patterns. Regime labels are assigned algorithmically and may not perfectly correspond to intuitive market descriptions. Market conditions can shift faster than the model adapts. Use regime classifications as one analytical input alongside other tools and judgment.

---

Source: https://stratcraft.ai/help/hmm-predictor/