HMM market regime strip: bear, range and bull states on the chart

The HMM Regime overlay fits a Gaussian hidden Markov model on the loaded bars and paints one colour strip per bar: the most likely regime (bear, range, bull) and the model's confidence. It observes price returns or the bar's order-flow delta.

Senzoukria · Documentation · Updated September 2026


Where to find it

Where
Chart → Indicators panel → group « Quant models » → « HMM Regime (quant) »
Default
Off. 3 states, observes price returns, fit window 500 bars, strip 6 px
Data needed
At least 30 usable observations inside the fit window; delta mode skips bars with zero volume

What it does

A hidden Markov model assumes the market switches between K regimes, each emitting observations from its own Gaussian distribution. Senzoukria fits that model on the bars currently loaded (Baum-Welch), decodes the most likely regime of every bar (Viterbi) and draws a thin strip at the top of each bar column in the colour of that regime. The strip's intensity carries the posterior probability, i.e. how confident the model is about that bar.

States are always sorted by mean, so state 0 is the most bearish and the last state the most bullish. With 3 states the labels are Bear, Range and Bull; with 2, Bear and Bull; with 4, Strong bear, Bear, Bull and Strong bull.

The fit is deterministic: means are seeded from the sample's own quantiles, there is no random initialisation, and the model is refitted on bar close only. Between two closes the fitted model is frozen and the live bar is decoded with a forward filter, so the strip does not flicker while a bar forms.

Settings

HMM Regime settings as listed in the Indicators panel
SettingDefaultWhat it changes
States3 — bear / range / bullNumber of hidden regimes: 2 (bear / bull), 3, or 4 (strong bear → strong bull)
ObservesPrice returnsObservation series: log returns in basis points, or Order-flow delta (bar delta / bar volume, in [−1, 1])
Fit window500 bars (60–2000, step 20)Only the last N bars are used for the fit; the code floors it at 50
Band height6 px (2–24)Height of the regime strip drawn above each bar
Tint the whole columnOffAlso tints the full bar column with the regime colour instead of the strip only
Bear / Range / Bull#ef4444 / #6b7280 / #22c55eColours of the sorted states; with 4 states the extremes reuse the bear and bull colours

How to use it

Use « Price returns » to answer the classic question — trend up, trend down, or chop — and « Order-flow delta » to classify aggression instead of price: two bars can print the same return with opposite flow, and only the delta source tells them apart.

Keep the fit window close to the horizon you trade. A regime fitted on three months of 1-minute bars is dominated by history that is not the market you are in; the 500-bar default is a compromise between stability and reactivity. If the strip disappears, the window does not contain 30 usable observations (for example a series with no variance).

Limits and pitfalls

  • The model reads the loaded bars only; a partially loaded session gives a partial fit.
  • Posterior confidence is the model's own certainty, not a probability that price will move.
  • The strip is a classification of the past and present bar, not a forecast; no result is promised.

This page in other languages

Frequently asked questions

Why do the regime colours never swap between repaints?
After each fit the states are relabelled in ascending order of mean, so index 0 is always the most bearish state. Without that step EM would number states arbitrarily and « state 2 » could mean bull on one repaint and bear on the next.
Does the HMM refit on every tick?
No. The model is refitted when a bar closes. While the live bar forms, the frozen model decodes the new observation with a single forward-filter step, which is cheap and keeps the strip stable.
What is the difference between the HMM strip and Hurst MR?
The HMM classifies regimes by the distribution of returns or delta. Hurst MR measures long-memory with a rescaled-range exponent and emits mean-reversion signals. They are separate overlays under the same « Quant models » group.

Keep reading