Skip to content
All library documents

Dual SuperTrend Strategy with Weighted KNN Trend Classification

Article TradingView scripts

Summary

This strategy builds two SuperTrend lines from moving-average price estimates and ATR bands, then classifies trend direction with a weighted k-nearest-neighbors procedure. For each line, it stores recent SuperTrend values and labels them according to whether a smoothed price measure is above a smoothed trend measure. The current value is compared with those samples, with closer neighbors receiving greater weight.

Long or short entries require agreement between both SuperTrend directions and both KNN classifications. The strategy offers long-only, short-only, or two-way trading, and uses SuperTrend-derived trailing stops for exits. Inputs control neighbor counts, data windows, smoothing lengths, ATR periods and multipliers, and moving-average type. The supplied source explains the mechanics but gives no backtest findings or evidence that its neighbor labels predict future returns; results may be sensitive to parameter choices and market conditions.

Key ideas

  • Two SuperTrend systems use ATR bands around a configurable moving-average price estimate.
  • A weighted KNN classifier labels trend samples based on smoothed price relative to smoothed SuperTrend values.
  • The strategy enters only when both SuperTrend directions and both classifications agree.
  • Trading direction can be restricted, and exits use stops derived from SuperTrend and ATR.
  • The document specifies tunable inputs but provides no evidence of predictive accuracy or profitability.

Tags

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