Skip to content
All library documents

KNN Similarity Signals for Moving Average Trend Following

Article Strategy library · Author: ChaoZhang

Summary

This document presents a proposed trend following strategy that compares a current price window with historical windows using Euclidean distance. It selects the nearest examples, averages their subsequent price changes, and combines that direction with a simple moving average: positive neighbor changes above the average indicate a long signal, while negative changes below it indicate a short signal. The listed parameters specify a neighbor count, a window length, and an average length.

The discussion identifies parameter sensitivity, computational cost, lag, overfitting, and reduced usefulness of historical analogies in volatile conditions. It suggests feature changes, faster neighbor search, volatility filters, and explicit risk controls. A BTC/USDT futures backtest period is provided, but no results are reported. The source implementation also raises a methodological concern: its distance loop compares the same current feature window against itself repeatedly, so the described search for distinct historical analogues is not clearly realized in the code. Its signal behavior should therefore be verified before drawing conclusions.

Key ideas

  • The proposed method ranks historical price windows by Euclidean distance from the current window.
  • It combines the average subsequent change of selected neighbors with a moving average filter.
  • The described conditions produce long signals for positive neighbor changes above the average and short signals for negative changes below it.
  • Neighbor count and window size can affect both computational load and signal behavior.
  • The provided code appears not to compare distinct historical windows as the prose describes, and no backtest results are given.

Tags

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