SuperTrend AI Clustering

SuperTrend AI Clustering

Introduction

The SuperTrend AI Clustering indicator is a sophisticated evolution of the classic SuperTrend. This new approach combines the traditional logic of the SuperTrend with algorithmic evaluation techniques to deliver more precise and adaptive signals.

By computing multiple SuperTrends with varying parameters and using an intelligent clustering system, this indicator automatically selects the most effective configuration for the current market context, dynamically adjusting support and resistance levels. This makes it an especially useful tool for traders seeking a more refined trend analysis.

What is the SuperTrend AI Clustering?

The traditional SuperTrend is a trend-following indicator based on the average price and the Average True Range (ATR). It signals trend reversals when the price crosses above or below a dynamic support or resistance level calculated from the ATR.

The SuperTrend AI Clustering extends this logic in an innovative way. Instead of relying on a single ATR multiplier, it calculates multiple SuperTrends using different factors. It then evaluates the recent historical performance of each and groups them using a clustering method inspired by the k-means algorithm.

Finally, it automatically selects the most appropriate group based on the user’s preference (best performance, average, or worst), and builds the final SuperTrend using parameters from that group only.

How the Indicator Works

The entire process can be summarized in three stages:

  1. Multi-SuperTrend Generation
    Several SuperTrends are calculated using different ATR multipliers (e.g., from 1 to 5 in 0.5 increments).
  2. Evaluation and Clustering
    Each SuperTrend is evaluated based on recent performance (measured by price movement) and grouped into one of three clusters: best, average, or worst performance. This grouping mimics a k-means algorithm.
  3. Cluster Selection and Final SuperTrend Construction
    The user selects which cluster to use for the final SuperTrend. This enables the indicator to adapt based on a more conservative, balanced, or aggressive trading approach.

Indicator Settings

Here are the customizable parameters available in the indicator:

  • length: ATR length (default 10). Defines sensitivity of range calculation.
  • minMult and maxMult: Range of ATR multipliers to evaluate.
  • step: Increment between multipliers (e.g., 0.5 for 1.0, 1.5, 2.0…).
  • perfAlpha: Performance memory used to smooth SuperTrend evaluations.
  • fromCluster: Cluster to use for the final SuperTrend:
    • 1 = Best performing
    • 2 = Average
    • 3 = Worst performing
  • maxiter: Maximum number of iterations for the clustering algorithm.
  • epsilon: Desired convergence precision for the algorithm.

These parameters allow the indicator to adapt its behavior based on the asset’s volatility or the trader’s style.

Interpretation and Trading Use

The signals generated by SuperTrend AI Clustering can be used for trend reversal indications or to confirm entry and exit points:

  • Bullish trend change: when the price crosses above the SuperTrend level.
  • Bearish trend change: when the price crosses below the SuperTrend level.
  • Color and transparency: the indicator changes color and opacity depending on trend changes, making it easier to identify key market shifts.

This adaptive approach represents a significant improvement over the traditional SuperTrend by dynamically adjusting its responsiveness to market conditions. (original code from LuxAlgo).

SuperTrend AI Clustering Code (ProBuilder)

Share this

Risk disclosure:

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

ProRealTime ITF files and other attachments : How to import ITF files into ProRealTime platform?

PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials

avatar
Register or

Likes

avatar avatar avatar
Related users ' posts
Nicolas Indeed, if you are not willing to loose, you will always win. Averaging down losers can carr...
David You're always safer going Long especially with averaging down on an index as the probability...
Oskar Bergvall  I noted Davids and Nicolas remarks. Could it be possible to make an indicator for contraria...
verdi55 Is there such a thing as a free lunch ?
maceng Thanks Nicolas for this great work! I would like to understand the math behind it in order t...
Nicolas Sorry I have no time to provide assistance for python programmers. Have a good day.
Nicolas You need to have enough bars loaded on your chart for the indicator to compute completely th...
verdi55 Working with separately calculated supertrend indicators in backtests is usually somewhat pr...
Nicolas Very interesting Verdi. Would be a great addition to the library, your own modified version ...
danhei Hi I am tryong to figure out how trist strategy works. I am new to pro real time. Can some...
Plop61 Hello,Thank you for sharing this beautiful strategy.Is it possible to indicate the code for ...
NoName Thank you very much for this fascinating trading system. It is still proving to be extremely...
DANY I did it on demo account; it's too dangerous for mea and I can not resist psychologically  ....
demoz How can a demo account be dangerous? Did you have it run live (on a demo account for exampl...
DANY Yes, I mean that I tried on a demo account for 2 months and it had work fine, like the BackT...
MikeGC I don't know if you have used the variables a and b to optimise the parameters for the Super...
gianpiero75 I have not optimized, I multiplied the parameters for 6 (5,8), to use them on the 4  hoursTF...
bertrandpinoy bonjour Mike j utilise TrendChaser V2.0 et quand il prend position cela ne programme pas le ...
eisi If i switch between different Markets, the Backgroundcolour will appear where it should not...
datageek How can I get alerts on colour change?
NAMBO40 Hello, I would like to add a 25 period SMA moving average. It's possible?
avatar
Anonymous We try to enter before that the market actually turn. We try to anticipate it. In which way ...
dwgfx David-1984 are you saying that you've already factored in the spread within the code?  If y...
avatar
Anonymous no, not in teh code... only in the backtest. The entry is only between 8/22 so the spread fo...
Doctrading
9 years ago
gianlox What markets did you feel ? Thanks..
wanjpt Doctrading, could you code an alert when the supertrend touches price for various timeframes...
JSTAR PRODUCTIONS Hi there DocTrading, I have run this Screener and it only seems to screem When trend line to...
Henry
9 years ago
SuperTrend
SuperTrend
4
Indicators
Nicolas Exit and relaunch PRT should fix this behavior.
verdi55 Thank you. After a restart, it is somewhat faster; however, it still takes about 3 minutes t...
Nicolas Good! thanks for sharing your own code! Please do so with other ones if you think you can im...

Top