Strategy Methodology

Markov Regime Detection

A probabilistic model that classifies the current market state into one of several regimes (e.g., bull, bear, sideways) to adapt strategy behavior.


Markets behave differently depending on the regime — trending, range-bound, volatile, calm. A strategy that works in one regime may lose money in another. Markov regime detection estimates which regime is currently active by modeling transitions between states as a stochastic process.

The botwir3 Markov module maintains a state estimate using hidden Markov model logic. Each cycle, the module evaluates recent price and volatility data, updates the regime probability, and adjusts its signal output accordingly. The module does not predict regime changes — it estimates the current regime and signals transitions when the probability crosses a threshold.

The user configures the number of regimes, the lookback window, and the transition sensitivity. A two-regime model (risk-on / risk-off) is simpler and more robust. A three-regime model adds a sideways state. More regimes increase expressiveness and overfitting risk equally.


Sources

Hamilton, J. D. (1989). A New Approach to the Economic Analysis of Nonstationary Time Series and the Business Cycle.” Econometrica, 57(2), 357–384.Introduced the Markov-switching model for detecting economic regime changes.

Used in

Markov Regime Detection module — builder


See this in action

coinbasealpacaoandabinance

Related

Trend Following / MomentumVolatilityBacktestingOverfitting

Build your bot →