Skip to content
All library documents

Using Hidden Markov Models to Identify Trading Regimes

Article MQL5 articles

Summary

The article explains how Gaussian, Gaussian mixture, and variational Gaussian hidden Markov models can describe financial time series as observations generated by unobserved market states. It covers model assumptions, emission distributions, covariance choices, parameter initialization, and Expectation-Maximization training. It then applies regime identification to a trading workflow, including setting transition priors, labeling regimes, testing strategies, and exporting fitted models for use in MetaTrader 5.

The author compares the model families and reports broadly similar performance in the experiments, favoring the simpler and faster Gaussian HMM in that setting. Mixture emissions may capture within-regime subpatterns but can increase overfitting; variational models require more careful prior choices. The article emphasizes prior matrices as a way to encourage stable regimes and notes that fewer states may suffice than in clustering. Its findings are specific to the described data and experiment: model performance may vary, markets are non-stationary, and cross-validation across folds is suggested but not evaluated.

Key ideas

  • An HMM represents observed market data as emissions from a sequence of latent states.
  • Gaussian HMMs suit continuous features, while mixture emissions can model richer within-state distributions.
  • The EM algorithm alternates between estimating state probabilities and updating model parameters.
  • Transition priors can influence the stability and persistence of inferred market regimes.
  • The reported model comparison is empirical and does not establish that one HMM family is best in other settings.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.