Volume SuperTrend AI (Expo)█ Overview
The Volume SuperTrend AI is an advanced technical indicator used to predict trends in price movements by utilizing a combination of traditional SuperTrend calculation and AI techniques, particularly the k-nearest neighbors (KNN) algorithm.
The Volume SuperTrend AI is designed to provide traders with insights into potential market trends, using both volume-weighted moving averages (VWMA) and the k-nearest neighbors (KNN) algorithm. By combining these approaches, the indicator aims to offer more precise predictions of price trends, offering bullish and bearish signals.
█ How It Works
Volume Analysis: By utilizing volume-weighted moving averages (VWMA), the Volume SuperTrend AI emphasizes the importance of trading volume in the trend direction, allowing it to respond more accurately to market dynamics.
Artificial Intelligence Integration - k-Nearest Neighbors (k-NN) Algorithm: The k-NN algorithm is employed to intelligently examine historical data points, measuring distances between current parameters and previous data. The nearest neighbors are utilized to create predictive modeling, thus adapting to intricate market patterns.
█ How to use
Trend Identification
The Volume SuperTrend AI indicator considers not only price movement but also trading volume, introducing an extra dimension to trend analysis. By integrating volume data, the indicator offers a more nuanced and robust understanding of market trends. When trends are supported by high trading volumes, they tend to be more stable and reliable. In practice, a green line displayed beneath the price typically suggests an upward trend, reflecting a bullish market sentiment. Conversely, a red line positioned above the price signals a downward trend, indicative of bearish conditions.
Trend Continuation signals
The AI algorithm is the fundamental component in the coloring of the Volume SuperTrend. This integration serves as a means of predicting the trend while preserving the inherent characteristics of the SuperTrend. By maintaining these essential features, the AI-enhanced Volume SuperTrend allows traders to more accurately identify and capitalize on trend continuation signals.
TrailingStop
The Volume SuperTrend AI indicator serves as a dynamic trailing stop loss, adjusting with both price movement and trading volume. This approach protects profits while allowing the trade room to grow, taking into account volume for a more nuanced response to market changes.
█ Settings
AI Settings:
Neighbors (k):
This setting controls the number of nearest neighbors to consider in the k-Nearest Neighbors (k-NN) algorithm. By adjusting this parameter, you can directly influence the sensitivity of the model to local fluctuations in the data. A lower value of k may lead to predictions that closely follow short-term trends but may be prone to noise. A higher value of k can provide more stable predictions, considering the broader context of market trends, but might lag in responsiveness.
Data (n):
This setting refers to the number of data points to consider in the model. It allows the user to define the size of the dataset that will be analyzed. A larger value of n may provide more comprehensive insights by considering a wider historical context but can increase computational complexity. A smaller value of n focuses on more recent data, possibly providing quicker insights but might overlook longer-term trends.
AI Trend Settings:
Price Trend & Prediction Trend:
These settings allow you to adjust the lengths of the weighted moving averages that are used to calculate both the price trend and the prediction trend. Shorter lengths make the trends more responsive to recent price changes, capturing quick market movements. Longer lengths smooth out the trends, filtering out noise, and highlighting more persistent market directions.
AI Trend Signals:
This toggle option enables or disables the trend signals generated by the AI. Activating this function may assist traders in identifying key trend shifts and opportunities for entry or exit. Disabling it may be preferred when focusing on other aspects of the analysis.
Super Trend Settings:
Length:
This setting determines the length of the SuperTrend, affecting how it reacts to price changes. A shorter length will produce a more sensitive SuperTrend, reacting quickly to price fluctuations. A longer length will create a smoother SuperTrend, reducing false alarms but potentially lagging behind real market changes.
Factor:
This parameter is the multiplier for the Average True Range (ATR) in SuperTrend calculation. By adjusting the factor, you can control the distance of the SuperTrend from the price. A higher factor makes the SuperTrend further from the price, giving more room for price movement but possibly missing shorter-term signals. A lower factor brings the SuperTrend closer to the price, making it more reactive but possibly more prone to false signals.
Moving Average Source:
This setting lets you choose the type of moving average used for the SuperTrend calculation, such as Simple Moving Average (SMA), Exponential Moving Average (EMA), etc.
Different types of moving averages provide various characteristics to the SuperTrend, enabling customization to align with individual trading strategies and market conditions.
-----------------
Disclaimer
The information contained in my Scripts/Indicators/Ideas/Algos/Systems does not constitute financial advice or a solicitation to buy or sell any securities of any type. I will not accept liability for any loss or damage, including without limitation any loss of profit, which may arise directly or indirectly from the use of or reliance on such information.
All investments involve risk, and the past performance of a security, industry, sector, market, financial product, trading strategy, backtest, or individual's trading does not guarantee future results or returns. Investors are fully responsible for any investment decisions they make. Such decisions should be based solely on an evaluation of their financial circumstances, investment objectives, risk tolerance, and liquidity needs.
My Scripts/Indicators/Ideas/Algos/Systems are only for educational purposes!
Aisupertrend
SuperTrend AI (Clustering) [LuxAlgo]The SuperTrend AI indicator is a novel take on bridging the gap between the K-means clustering machine learning method & technical indicators. In this case, we apply K-Means clustering to the famous SuperTrend indicator.
🔶 USAGE
Users can interpret the SuperTrend AI trailing stop similarly to the regular SuperTrend indicator. Using higher minimum/maximum factors will return longer-term signals.
The displayed performance metrics displayed on each signal allow for a deeper interpretation of the indicator. Whereas higher values could indicate a higher potential for the market to be heading in the direction of the trend when compared to signals with lower values such as 1 or 0 potentially indicating retracements.
In the image above, we can notice more clear examples of the performance metrics on signals indicating trends, however, these performance metrics cannot perform or predict every signal reliably.
We can see in the image above that the trailing stop and its adaptive moving average can also act as support & resistance. Using higher values of the performance memory setting allows users to obtain a longer-term adaptive moving average of the returned trailing stop.
🔶 DETAILS
🔹 K-Means Clustering
When observing data points within a specific space, we can sometimes observe that some are closer to each other, forming groups, or "Clusters". At first sight, identifying those clusters and finding their associated data points can seem easy but doing so mathematically can be more challenging. This is where cluster analysis comes into play, where we seek to group data points into various clusters such that data points within one cluster are closer to each other. This is a common branch of AI/machine learning.
Various methods exist to find clusters within data, with the one used in this script being K-Means Clustering , a simple iterative unsupervised clustering method that finds a user-set amount of clusters.
A naive form of the K-Means algorithm would perform the following steps in order to find K clusters:
(1) Determine the amount (K) of clusters to detect.
(2) Initiate our K centroids (cluster centers) with random values.
(3) Loop over the data points, and determine which is the closest centroid from each data point, then associate that data point with the centroid.
(4) Update centroids by taking the average of the data points associated with a specific centroid.
Repeat steps 3 to 4 until convergence, that is until the centroids no longer change.
To explain how K-Means works graphically let's take the example of a one-dimensional dataset (which is the dimension used in our script) with two apparent clusters:
This is of course a simple scenario, as K will generally be higher, as well the amount of data points. Do note that this method can be very sensitive to the initialization of the centroids, this is why it is generally run multiple times, keeping the run returning the best centroids.
🔹 Adaptive SuperTrend Factor Using K-Means
The proposed indicator rationale is based on the following hypothesis:
Given multiple instances of an indicator using different settings, the optimal setting choice at time t is given by the best-performing instance with setting s(t) .
Performing the calculation of the indicator using the best setting at time t would return an indicator whose characteristics adapt based on its performance. However, what if the setting of the best-performing instance and second best-performing instance of the indicator have a high degree of disparity without a high difference in performance?
Even though this specific case is rare its however not uncommon to see that performance can be similar for a group of specific settings (this could be observed in a parameter optimization heatmap), then filtering out desirable settings to only use the best-performing one can seem too strict. We can as such reformulate our first hypothesis:
Given multiple instances of an indicator using different settings, an optimal setting choice at time t is given by the average of the best-performing instances with settings s(t) .
Finding this group of best-performing instances could be done using the previously described K-Means clustering method, assuming three groups of interest (K = 3) defined as worst performing, average performing, and best performing.
We first obtain an analog of performance P(t, factor) described as:
P(t, factor) = P(t-1, factor) + α * (∆C(t) × S(t-1, factor) - P(t-1, factor))
where 1 > α > 0, which is the performance memory determining the degree to which older inputs affect the current output. C(t) is the closing price, and S(t, factor) is the SuperTrend signal generating function with multiplicative factor factor .
We run this performance function for multiple factor settings and perform K-Means clustering on the multiple obtained performances to obtain the best-performing cluster. We initiate our centroids using quartiles of the obtained performances for faster centroids convergence.
The average of the factors associated with the best-performing cluster is then used to obtain the final factor setting, which is used to compute the final SuperTrend output.
Do note that we give the liberty for the user to get the final factor from the best, average, or worst cluster for experimental purposes.
🔶 SETTINGS
ATR Length: ATR period used for the calculation of the SuperTrends.
Factor Range: Determine the minimum and maximum factor values for the calculation of the SuperTrends.
Step: Increments of the factor range.
Performance Memory: Determine the degree to which older inputs affect the current output, with higher values returning longer-term performance measurements.
From Cluster: Determine which cluster is used to obtain the final factor.
🔹 Optimization
This group of settings affects the runtime performances of the script.
Maximum Iteration Steps: Maximum number of iterations allowed for finding centroids. Excessively low values can return a better script load time but poor clustering.
Historical Bars Calculation: Calculation window of the script (in bars).