Skip to main content
Detecting Market Regime Changes
Engineering Learnings9 min readSeptember 19, 2026

Detecting Market Regime Changes

We detect market regime changes using a dual-clock system: a daily Hidden Markov Model for broad market classification and an intraday efficiency ratio…

By Tradewink Engineering
Share

Key takeaways

  • Use two regime clocks: a slow statistical model for the environment and a fast overlay for the session.
  • Store the regime a position was opened in, because an exit rule that compares entry regime to current regime needs both.
  • An efficiency ratio over recent bars is a cheap, interpretable trending-versus-choppy classifier that needs no training.
  • Let regime modulate size and gating before letting it modulate signals; sizing changes are easier to reason about and to reverse.
  • Transitional regimes deserve smaller size rather than a directional call, since transitions are where classification is least reliable.

Detecting market regime changes in an automated trading system requires a multi-resolution approach. We use a daily Hidden Markov Model on broad market proxy returns to classify the overall market environment, and a separate intraday efficiency ratio on five-minute bars to assess session-specific conditions. These two systems operate on different clocks, providing distinct but complementary views of market dynamics.

What went wrong

Our initial automated trading system at Tradewink suffered a significant production failure due to a misinterpretation of market conditions. We had a regime detection mechanism, but it was too slow to react to rapid shifts within a trading day. Specifically, the system identified a "trending" regime based on daily data, leading it to deploy capital with a certain risk profile. However, within hours, the market transitioned to a "choppy" state, characterized by high intraday volatility and a lack of directional conviction. Our system, still operating under the "trending" classification from the daily model, failed to adapt its position sizing or exit strategy. This resulted in substantial unrealized losses as positions were held through a period of adverse, choppy price action that the system was not equipped to handle.

Why it happens

The core issue stems from the temporal mismatch between the data used for regime detection and the trading system's operational frequency. A Hidden Markov Model (HMM) applied to daily returns, while effective at identifying broader market states (e.g., trending, mean-reverting, high volatility), has a significant lag. The model requires a sufficient history of daily returns to converge on a classification. By the time the daily HMM updates and signals a regime change, the market may have already moved substantially within the current trading session. If the trading system relies solely on this slow-moving daily classification, it will inevitably be out of sync with intraday market realities. This is akin to trying to navigate a busy city street using only a weekly traffic report; you miss the immediate congestion and hazards.

Furthermore, feeding the wrong data shape to the regime detection model is a common integration mistake. Our HMM expects a list of returns, not raw price data or a different time frame. Attempting to feed it price frames or intraday bars directly, without proper transformation, leads to incorrect model inputs and, consequently, flawed regime classifications. This can happen during initial integration or when refactoring code, where assumptions about data format are inadvertently violated.

What we changed

To address these shortcomings, we implemented a dual-clock regime detection system. The first component remains a Hidden Markov Model that runs on daily returns of a broad market proxy. This model classifies the overarching market environment before any trading scans begin for the day. This provides a foundational understanding of the expected market behavior.

The critical addition is a separate, faster intraday overlay. This overlay computes an "efficiency ratio" on five-minute bars of the same broad market proxy. The efficiency ratio, a measure of how much price has moved relative to its range, helps label the current session as trending, choppy, or neutral. This intraday assessment runs on a different clock, allowing for much more granular and timely feedback on market conditions within the trading day.

These two systems feed into our trading logic in three key areas:

  1. Pre-scan gating: The daily regime classification acts as a gatekeeper. If the HMM identifies an unfavorable regime (e.g., extremely high volatility or a highly uncertain transition period), we can choose to skip certain scans or reduce the overall trading activity for the day.
  2. Regime-adjusted position sizing: The daily regime classification informs our position sizing. We deliberately reduce the size of our positions during periods identified as volatile or transitioning by the HMM. This is a crucial risk management step to avoid overexposure when market predictability is low.
  3. Exit path: This is where the intraday overlay becomes paramount. Positions are entered with a record of the regime they were initiated in, as determined by the daily HMM. When the intraday overlay signals a flip from a trending to a choppy state, this recorded entry regime is compared against the current intraday label. This comparison is what makes a regime-shift exit decidable. If a position was entered in a trending regime and the intraday conditions abruptly turn choppy, it triggers a review and potential exit, even if the daily HMM hasn't yet updated to reflect the new intraday reality.

Furthermore, we integrated a reinforcement-learning selector that adjusts strategy weights based on the detected regime. This adaptive strategy weighting only functions effectively because the regime is stored as a persistent attribute of each trade. When a trade is initiated, its entry regime (from the daily HMM) is logged. The RL selector then uses this stored attribute, along with the current intraday conditions, to dynamically adjust the weights of different trading strategies. This ensures that our system is not just aware of the regime but actively adapting its operational parameters to it.

How to check your own system

To ensure your automated trading system can effectively detect and react to market regime changes, conduct the following checks:

  • Data Granularity Mismatch: Verify that your regime detection logic uses data at a frequency appropriate for your trading system's operational speed. If your system trades on minute-by-minute or hour-by-hour basis, a daily regime indicator alone is insufficient. Consider a secondary, faster regime indicator.
  • Input Shape Validation: For any statistical models used in regime detection (like HMMs), confirm that the input data shape precisely matches the model's requirements. A common error is feeding price series directly when returns are expected, or vice-versa.
  • Lag Analysis: Quantify the lag between a significant market regime shift and your system's detection and reaction. If this lag is consistently longer than the duration of profitable opportunities within that shift, your detection is too slow.
  • Conditional Logic Review: Examine how regime information is used. Does it influence pre-trade gating, position sizing, or exit strategies? Ensure these connections are explicit and correctly implemented.
  • State Persistence: Confirm that regime information is persistently stored with trades. This is crucial for adaptive strategies and for making informed exit decisions based on entry conditions versus current conditions.

This dual-clock approach, combining the broad strokes of daily HMMs with the fine details of intraday efficiency ratios, has been instrumental in building a more resilient automated trading system at Tradewink.

Disclaimer

This article describes engineering decisions in a trading system. It is not investment advice. Trading involves substantial risk of loss and is not suitable for all investors. Past performance does not guarantee future results. Always do your own research and consider your financial situation before trading.

Frequently asked questions

What is market regime detection?

It is the classification of the current market environment into a small number of states, typically along trend and volatility axes, so a strategy can adapt instead of assuming one set of conditions. The states are usually inferred statistically rather than declared by hand.

How do hidden Markov models apply to trading?

A hidden Markov model assumes an unobservable state generates the returns you can see, and infers the most likely state sequence from the data. Applied to market returns it produces labels such as low-volatility trending or high-volatility mean-reverting, with transition probabilities between them. It describes the present better than it predicts the next state.

Should a strategy switch off in the wrong regime?

Reducing size is usually more robust than switching off, because regime classification is least reliable exactly during transitions, which is when a hard switch would fire. Hard gates make more sense for specific, well-understood conditions than as a general regime response.

Related Topics

market regime detectionhidden markov model tradingtrending vs choppy marketvolatility regimeadaptive trading strategyintraday market conditions
TW

Tradewink builds explainable market research for self-directed traders. Build a watchlist, inspect signal reasoning and risk context, and paper-track ideas before you decide. Live broker workflows are invite-only when available.

Found this useful? Share it.
Share

Put this knowledge to work

Tradewink uses AI to scan hundreds of stocks daily and delivers trade ideas with full signal breakdowns — free to start.

Build a Watchlist

Save a signal preview for later

Get a concise AI signal example in your inbox, then build a watchlist when you are ready. No spam, unsubscribe anytime.

Start with free AI trade ideas

See how Tradewink turns market structure, momentum, and risk rules into trade-ready signals. Free to start, with your broker staying in control.

Enter the email address where you want to receive a Tradewink AI signal preview.

More in Engineering Learnings