HMM Regime Pass Node
Hidden Markov Model Regime Detection — Series Input
Overview
The HMM Regime Pass Node applies a Hidden Markov Model to a series input to classify market regimes. It infers latent states (e.g., trending up, trending down, ranging) from observed return patterns — assigning each bar a regime label from 0 to numStates−1.
Unlike threshold-based regime filters, HMM learns the statistical properties of each regime from the data and accounts for the probability of transitioning between regimes. As a Pass node it operates on any numeric series, enabling regime classification of derived indicator streams or custom price transformations.
Algorithm
Parameters
| Parameter | Default | Description |
|---|---|---|
| period | 100 | Rolling window of bars used to fit the HMM at each step |
| numStates | 3 | Number of hidden market regimes to detect (2–5 recommended) |
Inputs & Outputs
| Slot | Direction | Type | Description |
|---|---|---|---|
| input | Input | { values, timestamps } | Any numeric series for regime classification |
| values | Output | (number | null)[] | Regime labels [0, numStates−1]; nulls during warm-up |
| timestamps | Output | number[] | Unix timestamps aligned to input |
Use Cases
Regime-Conditional Strategy Switching
Map state labels to strategy modes — e.g., state 0 = ranging (activate mean-reversion), state 1 = low-volatility trend (activate trend-following), state 2 = high-volatility (reduce position size or step aside).
Volatility Regime Detection
Feed a volatility series (ATR, realized volatility) into HMM Pass to identify low, medium, and high volatility regimes — enabling dynamic position sizing that scales down exposure in detected high-volatility states.
Regime Persistence Filter
Use regime state persistence (how many bars the current state has been active) as a confidence filter — only act on signals that have been in a consistent regime for multiple bars, filtering one-bar false positives.
Tips & Best Practices
State Label Ordering Is Not Fixed
HMM state labels (0, 1, 2) are assigned arbitrarily by the algorithm — state 0 may not always be "bearish." Post-process state labels by comparing each state's mean return to assign semantic meaning (bullish/bearish/neutral).
Large Period Required
HMM fitting requires sufficient data — the default period=100 is a minimum for 3 states. For more states (4–5), use period=150–200. Too few bars per state leads to unstable, frequently shifting regime estimates.
Computationally Intensive
HMM fitting (Baum-Welch EM) runs at each bar update — this is expensive compared to most indicators. If performance is a concern, increase the period to reduce re-fitting frequency or use this on higher timeframes only.