Concept
Hidden Markov / Markov-switching Regimes
Hidden Markov / Markov-switching Regimes are Machine Learning concepts. The Library holds 2 implementations, each one a working definition you can pull into Quant.
Top Hidden Markov / Markov-switching Regimes indicators
2 total
What are Hidden Markov / Markov-switching Regimes?
Hidden Markov and Markov-switching models describe the market as moving between a small number of unobserved states, or regimes, such as quiet uptrend, volatile selloff, and rangebound chop. The state is hidden: only its fingerprints are observed, typically returns whose mean and variance differ by state. The state itself follows a Markov chain, meaning the probability of switching depends only on the current state. Persistence enters through the transition matrix: fitted self-transition probabilities are typically high, so regimes tend to continue and switches are comparatively rare.
Fitting the model, classically with the Baum-Welch expectation-maximization algorithm, estimates each state's return distribution and the matrix of transition probabilities; decoding then assigns each bar a probability of belonging to each regime. Markov-switching regression, introduced to econometrics by James Hamilton, applies the same idea to model parameters that switch with the latent state. The states carry no built-in meaning; labels like bull or bear come from inspecting the fitted parameters afterward. On charts the output is usually consumed as a trend regime label or filter.
How traders use it
- As a strategy switch: trend-following logic is enabled in the trending state and mean-reversion logic in the quiet state, with high-volatility states treated as stand-aside, a model-driven form of volatility regime classification.
- As chart context: bars are colored by the most probable state, or the regime probability is plotted so fading confidence is visible before a switch is declared.
- As an early-warning read: a rising transition probability suggests the current regime is aging, even before the most likely state flips.
Related concepts · Regimes & clustering
Concept family
Machine Learning
32 concepts mapped · 21 in the Library
Hidden Markov / Markov-switching Regimes FAQ
What do the hidden states in a Hidden Markov Model actually mean?
Nothing intrinsic. Each state is a statistical cluster defined by its fitted return distribution, commonly a Gaussian with its own mean and variance. Interpretations like bull, bear, or high-volatility are assigned afterward by inspecting those parameters. Different lookbacks, feature choices, or state counts can produce different regimes, so labels should be checked against the fit rather than assumed.
How does an HMM regime filter differ from k-means clustering?
K-means regime clustering assigns each bar to the nearest cluster independently, so labels can flip bar to bar. An HMM adds time structure through transition probabilities, which in fitted models typically discourage rapid switching, usually yielding more persistent regimes at the cost of heavier estimation. Both require choosing the number of states in advance, and neither guarantees the fitted regimes persist out of sample.
Build Hidden Markov / Markov-switching Regimes your way.
Quant writes, tests, and refines it with you — then it runs on LuxAlgo charting or ports to TradingView.

