Skip to content
All library documents

Filtering Trend-Following Trades with Hidden Markov Market Regimes

Article QuantStart

Summary

This article describes using a Gaussian Hidden Markov Model (HMM) as a risk filter for a simple S&P 500 trend-following strategy. The model is trained on historical SPY adjusted returns to identify latent volatility regimes. A QSTrader risk manager then permits new long trades in low-volatility states, blocks new entries in high-volatility states, and allows existing positions to close when the strategy signals an exit. The underlying strategy uses a short and long simple moving average crossover.

The model is fitted on data from 1993 through 2004, then applied without retraining to a 2005–2014 backtest, providing an out-of-sample setup. The article explains return calculation, model serialization, and integration with the trading framework. It presents the filter as a way to avoid trend trades during volatile periods, but does not provide enough reported performance results here to establish that the approach improves returns or risk-adjusted performance. Regime labels are inferred from past returns, and fixed training may limit the filter as market behavior changes.

Key ideas

  • An HMM can infer latent market states from observed asset returns.
  • The risk manager blocks new long entries during predicted high-volatility regimes.
  • The example strategy uses a short and long moving average crossover on SPY.
  • The model is trained on earlier data and used without retraining in a later backtest.
  • The article describes a proposed risk overlay, but the available text does not establish its performance benefit.

Tags

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