Skip to content
All library documents

Using K-Means Clusters in a Walk-Forward Trading Framework

Article Robot Wealth

Summary

The article outlines a framework that groups daily candle patterns with k-means, then tests whether particular clusters support long or short trades. Its sample features are the day’s high, low, and close relative to its open. Historical observations are exported to R, where clustering models are fitted; Zorro then assigns new observations to clusters and applies trading rules. The framework includes a single-model mode and a rolling walk-forward process that builds models, measures each cluster-direction strategy in training data, and selects candidates for later testing using a performance threshold.

A reported single-model EUR/JPY backtest shows positive results, but the excerpt does not establish that they generalize. The walk-forward procedure is intended to address changing samples and selection, yet the supplied text is incomplete and does not give aggregate out-of-sample results. Choices such as cluster count, features, assets, and threshold remain tunable, creating scope for selection bias. The author suggests testing richer features and patterns, but those extensions are proposals rather than demonstrated findings.

Key ideas

  • The framework clusters daily candle shape using high, low, and close relative to the open.
  • A single-model workflow builds clusters on historical data and tests cluster-specific long or short rules.
  • The walk-forward workflow trains models and evaluates candidate strategies across successive periods.
  • Training performance is compared with a threshold to choose strategies for out-of-sample testing.
  • The reported EUR/JPY example is limited evidence, and tuning model choices can introduce selection bias.

Tags

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