HMM Regime Filter | Market State
Jun 6, 2026

The HMM Regime Filter indicator classifies current market conditions into one of three hidden states—Trend Up, Range, or Trend Down—using a Bayesian forward filtering model to provide real-time context for strategy selection.
Usage
The Usage section describes how the script can be used to distinguish between trending and mean-reverting environments. It serves as a context layer rather than a trade trigger; users can use the identified regime to determine which technical tools to prioritize.
- Trend Up / Trend Down: In these regimes, trend-following logic such as pullbacks, breakouts, and momentum continuation is typically more effective.
- Range: When the model identifies a ranging state, mean-reversion strategies, such as fading price extremes or using oscillators, are generally preferred.
- Uncertain: If no regime meets the dominance threshold, the model reports an uncertain state, suggesting a period of indecision where traders might reduce position sizes or stand aside.
The indicator provides visual feedback through a probability ribbon in a separate pane, bar coloring on the main chart, and a status dashboard. The dashboard tracks the duration of the current regime ("Held for"), allowing users to gauge the stability of the current market state.
Details
The HMM Regime Filter utilizes a Hidden Markov Model (HMM) to infer market states that are not directly observable. It updates the probability of each regime on every bar close through two primary components:
- Transition Model: This defines the probability of moving between states. The model is structured so that trends typically decay into a Range state before reversing, reflecting the natural cycle of most financial markets.
- Gaussian Emissions: The model compares current price behavior (normalized returns) against expected behavior for each state. These emissions scale automatically to the instrument's volatility using a lookback window.
To ensure stability and prevent "flickering" (rapid switching between states), the script implements three mechanisms:
- Stickiness: A setting that dictates the model's preference to remain in its current state unless significant evidence suggests a shift.
- Confirmation Rule: Requires a new regime to maintain its lead for a specific number of consecutive bars before the official state updates.
- Dominance Threshold: A confidence requirement that prevents the model from committing to a regime if the leading probability is too low.
Settings
Model
- Observation smoothing: EMA length applied to normalized returns before processing. Higher values reduce noise on fast timeframes.
- Scaling window: The lookback period used to calibrate the model to the specific instrument's volatility.
- Regime separation: Determines the distance between the Trend Up and Trend Down means in standard deviations. Higher values result in more "Range" classifications.
Stability
- Stickiness (stay probability): Controls the diagonal of the transition matrix. Higher values create more persistent, stable regimes.
- Confirmation bars: The number of consecutive bars a new regime must be the most likely before it is officially confirmed.
- Dominance threshold: The minimum probability required for a regime to be considered active; otherwise, the state is marked as "uncertain."
Display
- Probability ribbon: Toggles the visibility of the flowing probability streams in the indicator pane.
- Ribbon smoothing: Applies visual smoothing to the ribbon streams without affecting the underlying logic.
- Dark pane background / Tint pane: Controls the aesthetic background and regime-based tinting of the indicator pane.
- Color price bars: Colors the main chart candles based on the confirmed market regime.
- Show dashboard: Toggles the data table containing live probabilities and regime duration.
FAQ
How do I interpret the "Held for" counter in the dashboard? The "Held for" counter indicates how many bars the current regime has been official. High numbers suggest a stable, established environment, while frequent resets indicate choppy or transitional market conditions.
Why does the indicator stay on "uncertain" for several bars? The model requires a warm-up period defined by the "Scaling window" to calibrate to the instrument. It may also show "uncertain" if the "Dominance threshold" is set too high for the current market conviction.
How do I access the HMM Regime Filter | Market State? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Unlock Unlimited Access to the LuxAlgo Library
Upgrade your plan to get all indicators, strategies, charts, and full access to Quant, our AI agent.
Trading & investing are risky and many will lose money in connection with trading and investing activities. All content on this site is not intended to, and should not be, construed as financial advice. Decisions to buy, sell, hold or trade in securities, commodities and other investments involve risk and are best made based on the advice of qualified financial professionals. Past performance does not guarantee future results.
Hypothetical or Simulated performance results have certain limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, including, but not limited to, lack of liquidity. Simulated trading programs in general are designed with the benefit of hindsight, and are based on historical information. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.
Testimonials appearing on this website may not be representative of other clients or customers and is not a guarantee of future performance or success.
As a provider of technical analysis tools and strategies, we do not have access to the personal trading accounts or brokerage statements of our customers. As a result, we have no reason to believe our customers perform better or worse than traders as a whole based on any content, tool, or platform feature we provide.
Charts used on this site are by TradingView in which the majority of our technical indicators are built on. TradingView® is a registered trademark of TradingView, Inc. www.TradingView.com TradingView® has no affiliation with the owner, developer, or provider of the Services described herein.
Market data is provided by CBOE, CME Group, BarChart, Massive, CoinAPI. Select U.S. equities data is provided through Massive. CBOE BZX real-time U.S. equities data is licensed from CBOE and provided through BarChart. Real-time futures data is licensed from CME Group and provided through BarChart. Select cryptocurrency data, including major coins, is provided through CoinAPI. All data is provided “as is” and should be verified independently for trading purposes.
This does not represent our full Disclaimer. Please read our full disclaimer.
© 2026 LuxAlgo Global, LLC.

