OPEN-SOURCE SCRIPT

Machine Learning Trendlines Cluster [LuxAlgo]

29 979
The ML Trendlines Cluster indicator allows traders to automatically identify trendlines using a machine learning algorithm based on k-means clustering and linear regression, highlighting trendlines from clustered prices.

For trader's convenience, trendlines can be filtered based on their slope, allowing them to filter out trendlines that are too horizontal, or instead keep them depending on the user-selected settings.

🔶 USAGE

syot kilat

Traders only need to set the number of trendlines (clusters) they want the tool to detect and the algorithm will do the rest.

By default the tool is set to detect 4 clusters over the last 500 bars, in the image above it is set to detect 10 clusters over the same period.

This approach only focuses on drawing trendlines from prices that share a common trading range, offering a unique perspective to traditional trendlines. Trendlines with a significant slope can highlight higher dispersion within its cluster.

🔹 Trendline Slope Filtering

syot kilat

Traders can filter trendlines by their slope to display only steep or flat trendlines relative to a user-defined threshold.

The image above shows the three different configurations of this feature:

  • Filtering disabled
  • Filter slopes above threshold
  • Filter slopes below threshold


🔶 DETAILS

syot kilat

K-means clustering is a popular machine-learning algorithm that finds observations in a data set that are similar to each other and places them in a group.

The process starts by randomly assigning each data point to an initial group and calculating the centroid for each. A centroid is the center of the group. K-means clustering forms the groups in such a way that the variances between the data points and the centroid of the cluster are minimized.

The trendlines are displayed according to the linear regression function calculated for each cluster.

🔶 SETTINGS

  • Window Size: Maximum number of bars to get data from
  • Clusters: Maximum number of clusters (trendlines) to detect


🔹 Optimization

  • Maximum Iteration Steps: Maximum loop iterations for cluster computation


🔹 Slope Filter

  • Threshold Multiplier: Multiplier applied to a volatility measure, higher multiplier equals higher threshold
  • Filter Slopes: Enable/Disable Trendline Slope Filtering, select to filter trendlines with slopes ABOVE or BELOW the threshold


🔹 Style

  • Upper Zone: Color to display in the top zone
  • Lower Zone: Color to display in the bottom zone
  • Lines: Style for the lines
  • Size: Line size

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.