Markets have moods. Some weeks prices drift calmly upward. Other weeks, every headline sends stocks whipsawing 3% in an hour. A Hidden Markov Model (HMM) reads those moods automatically, classifying every day as calm, normal, or stormy, so you can adjust your trading strategy before the weather changes.
This guide assumes zero machine learning knowledge. If you trade stocks and want to understand what that "HMM LOW VOL" badge on your dashboard means, you are in the right place.
This is educational content only, not financial advice. Always do your own research and consult a qualified advisor before making investment decisions.
↓ Scroll to start
Three States of Volatility
Think of the stock market like weather. Some days are sunny, some are cloudy, and some are full-blown storms. The HMM sorts every trading day into one of three regimes based on how wildly prices are swinging.
Low Volatility
Clear skies. Prices drift smoothly along a trend. Small daily moves, calm and confident.
Normal Volatility
Partly cloudy. Prices zigzag around a path. Moderate daily swings, business as usual.
High Volatility
Thunderstorm. Wild price swings and gap moves. Fear and uncertainty dominate the tape.
How It Learns Patterns
The HMM looks at two things for every day: the daily return (how much the price changed) and the realized volatility (how big the recent swings have been). Then it finds three natural clusters.
Each dot is one trading day. The x-axis is the daily return; the y-axis is the 10-day rolling volatility. Click Cluster to watch the HMM sort them into three groups.
For those curious about what is actually happening mathematically. The HMM has three components:
1. Hidden states. The model assumes $K = 3$ hidden states (Low Vol, Normal, High Vol). At each time step $t$, the market is in exactly one state $z_t \in \{1, 2, 3\}$.
2. Transition matrix. The probability of moving from state $i$ to state $j$ tomorrow:
Each row sums to 1. The diagonal entries $A_{ii}$ are typically large (0.95+), meaning regimes are sticky. The transition risk shown on the badge is simply $1 - A_{ii}$ for the current state $i$.
3. Emission model. In each state $k$, the observed features (daily return $r_t$ and rolling volatility $\sigma_t$) follow a Gaussian distribution:
Where $\boldsymbol{\mu}_k$ is the mean vector for state $k$. In our implementation, all states share a single covariance matrix $\boldsymbol{\Sigma}$ (tied covariance), which models feature correlations while keeping the model stable. The states differ in their means: Low Vol has small $|\boldsymbol{\mu}_k|$, High Vol has large $|\boldsymbol{\mu}_k|$.
4. Learning (Baum-Welch / EM). The parameters ($A$, $\boldsymbol{\mu}_k$, $\boldsymbol{\Sigma}_k$) are learned from historical price data using the Expectation-Maximization algorithm. We run 10 random restarts and keep the model with the highest log-likelihood:
5. Decoding. Once trained, the Viterbi algorithm finds the most likely state sequence, and the forward algorithm gives us the posterior probabilities $P(z_t = k \mid \mathbf{x}_{1:T})$ shown in the stacked area chart.
Reading the Dashboard Badge
On the Trader Koo stock chart, you will see a badge like this at the top. Let us break down exactly what each part means.
Transition Risk
The HMM does not just tell you today's mood. It also learns how likely the market is to switch moods. This is captured in a 3×3 transition matrix, a table of probabilities.
Read it left to right: "If the market is currently in [row], what is the probability it will be in [column] tomorrow?" Notice how the diagonal is bright. Regimes tend to persist.
Days in Current State
The "(5D)" in the badge tells you how many consecutive days the market has stayed in the same regime. A long streak means the regime is well-established. A short streak means it might have just flipped.
Click any circle to cycle its regime (Low → Normal → High → Low). The counter below shows the current streak length, counting backwards from the last day until the regime changes.
How to Use This
Understanding the regime adds context to your analysis. Here are some ways traders think about each state. Here is a practical playbook for each state.
Low Volatility
- Trends persist. Ride momentum. Breakouts tend to follow through.
- Tighter ranges. Smaller daily swings mean risk per trade is naturally lower.
- Trends persist. Calm markets tend to trend more smoothly with fewer false reversals.
- Selling premium? Low IV means options are cheap. Not ideal for selling, but great for buying cheap protection.
Normal Volatility
- Standard conditions. The market is behaving within typical parameters.
- Balanced risk. Neither unusually calm nor unusually volatile.
- Watch for transitions. Normal can shift to either calm or stormy. Monitor the shift risk % closely.
- Both trend and mean-reversion strategies can work. Be flexible.
High Volatility
- Elevated risk. Daily swings are large, meaning the same position carries more dollar risk.
- Wider ranges. Price tends to move further from mean, so narrow levels get tested more often.
- Mean-reversion works. Big moves tend to snap back. Fade extremes.
- Patience pays. High-vol regimes eventually resolve. Some traders prefer to wait for clearer conditions.