All indicators

Machine Learning Trendlines Cluster

By LuxAlgoMar 19, 2025

Static chart image

Machine Learning Trendlines Cluster hands the drawing of trendlines to an algorithm. K-means clustering groups recent bars into price ranges that traded together, and a linear regression fitted through each cluster is plotted as a trendline (4 clusters over the past 500 bars by default). The lines describe where price actually spent its time rather than connecting two hand-picked pivots.

How to Trade the Machine Learning Trendlines Cluster?

  • Set the line count: define how many clusters (trendlines) to detect and let the algorithm handle the calculation; raising the count uncovers finer lines inside the same window.
  • Read slope as variance: steeper lines come from clusters with greater internal variance, potentially tracing the segments where price moved hardest.
  • Filter by slope: keep only lines above or below a volatility-scaled threshold to emphasize prominent gradients, or favor the flatter, range-like ones.

Under the hood, k-means clustering repeatedly assigns bars to their nearest group and recenters each group until variance stops improving, so the plotted regressions settle onto stable price groupings.

Machine Learning Trendlines Cluster Settings

  • Window Size: maximum number of bars data is gathered from.
  • Clusters: maximum number of clusters, and therefore trendlines, to identify.
  • Maximum Iteration Steps: caps the clustering loop so computation stays efficient.
  • Threshold Multiplier: volatility-based multiplier for the slope filter; higher values increase its sensitivity.
  • Filter Slopes: toggles slope filtering and whether lines above or below the threshold are kept.
  • Style inputs (Upper Zone, Lower Zone, Lines, Size) control zone colors, line style, and thickness.

Frequently Asked Questions

Free indicator

Get free access to this indicator on the platforms below.

TradingView
NinjaTrader
MetaTrader 4/5
Original indicatorBuilt in-house by LuxAlgo

The Library is free. Quant makes it yours.

Pull any concept or indicator into Quant: rebuild it, retune it, or turn it into a backtested strategy of your own.