Quadratic & Linear Time Series Regression [SS]Hey everyone,
Releasing the Quadratic/Linear Time Series regression indicator.
About the indicator:
Most of you will be familiar with the conventional linear regression trend boxes (see below):
This is an awesome feature in Tradingview and there are quite a few indicators that follow this same principle.
However, because of the exponential and cyclical nature of stocks, linear regression tends to not be the best fit for stock time series data. From my experience, stocks tend to fit better with quadratic (or curvlinear) regression, which there really isn't a lot of resources for.
To put it into perspective, let's take SPX on the 1 month timeframe and plot a linear regression trend from 1930 till now:
You can see that its not really a great fit because of the exponential growth that SPX has endured since the 1930s. However, if we take a quadratic approach to the time series data, this is what we get:
This is a quadratic time series version, extended by up to 3 standard deviations. You can see that it is a bit more fitting.
Quadratic regression can also be helpful for looking at cycle patterns. For example, if we wanted to plot out how the S&P has performed from its COVID crash till now, this is how it would look using a linear regression approach:
But this is how it would look using the quadratic approach:
So which is better?
Both linear regression and quadratic regression are pivotal and important tools for traders. Sometimes, linear regression is more appropriate and others quadratic regression is more appropriate.
In general, if you are long dating your analysis and you want to see the trajectory of a ticker further back (over the course of say, 10 or 15 years), quadratic regression is likely going to be better for most stocks.
If you are looking for short term trades and short term trend assessments, linear regression is going to be the most appropriate.
The indicator will do both and it will fit the linear regression model to the data, which is different from other linreg indicators. Most will only find the start of the strongest trend and draw from there, this will fit the model to whatever period of time you wish, it just may not be that significant.
But, to keep it easy, the indicator will actually tell you which model will work better for the data you are selecting. You can see it in the example in the main chart, and here:
Here we see that the indicator indicates a better fit on the quadratic model.
And SPY during its recent uptrend:
For that, let's take a look at the Quadratic Vs the Linear, to see how they compare:
Quadratic:
Linear:
Functions:
You will see that you have 2 optional tables. The statistics table which shows you:
The R Squared to assess for Variance.
The Correlation to assess for the strength of the trend.
The Confidence interval which is set at a default of 1.96 but can be toggled to adjust for the confidence reading in the settings menu. (The confidence interval gives us a range of values that is likely to contain the true value of the coefficient with a certain level of confidence).
The strongest relationship (quadratic or linear).
Then there is the range table, which shows you the anticipated price ranges based on the distance in standard deviations from the mean.
The range table will also display to you how often a ticker has spent in each corresponding range, whether that be within the anticipated range, within 1 SD, 2 SD or 3 SD.
You can select up to 3 additional standard deviations to plot on the chart and you can manually select the 3 standard deviations you want to plot. Whether that be 1, 2, 3, or 1.5, 2.5 or 3.5, or any combination, you just enter the standard deviations in the settings menu and the indicator will adjust the price targets and plotted bands according to your preferences. It will also count the amount of time the ticker spent in that range based on your own selected standard deviation inputs.
Tips on Use:
This works best on the larger timeframes (1 hour and up), with RTH enabled.
The max lookback is 5,000 candles.
If you want to ascertain a longer term trend (over years to months), its best to adjust your chart timeframe to the weekly and/or monthly perspective.
And that's the indicator! Hopefully you all find it helpful.
Let me know your questions and suggestions below!
Safe trades to all!
Regressions
Relational Quadratic Kernel Channel [Vin]The Relational Quadratic Kernel Channel (RQK-Channel-V) is designed to provide more valuable potential price extremes or continuation points in the price trend.
Example:
Usage:
Lookback Window: Adjust the "Lookback Window" parameter to control the number of previous bars considered when calculating the Rational Quadratic Estimate. Longer windows capture longer-term trends, while shorter windows respond more quickly to price changes.
Relative Weight: The "Relative Weight" parameter allows you to control the importance of each data point in the calculation. Higher values emphasize recent data, while lower values give more weight to historical data.
Source: Choose the data source (e.g., close price) that you want to use for the kernel estimate.
ATR Length: Set the length of the Average True Range (ATR) used for channel width calculation. A longer ATR length results in wider channels, while a shorter length leads to narrower channels.
Channel Multipliers: Adjust the "Channel Multiplier" parameters to control the width of the channels. Higher multipliers result in wider channels, while lower multipliers produce narrower channels. The indicator provides three sets of channels, each with its own multiplier for flexibility.
Details:
Rational Quadratic Kernel Function:
The Rational Quadratic Kernel Function is a type of smoothing function used to estimate a continuous curve or line from discrete data points. It is often used in time series analysis to reduce noise and emphasize trends or patterns in the data.
The formula for the Rational Quadratic Kernel Function is generally defined as:
K(x) = (1 + (x^2) / (2 * α * β))^(-α)
Where:
x represents the distance or difference between data points.
α and β are parameters that control the shape of the kernel. These parameters can be adjusted to control the smoothness or flexibility of the kernel function.
In the context of this indicator, the Rational Quadratic Kernel Function is applied to a specified source (e.g., close prices) over a defined lookback window. It calculates a smoothed estimate of the source data, which is then used to determine the central value of the channels. The kernel function allows the indicator to adapt to different market conditions and reduce noise in the data.
The specific parameters (length and relativeWeight) in your indicator allows to fine-tune how the Rational Quadratic Kernel Function is applied, providing flexibility in capturing both short-term and long-term trends in the data.
To know more about unsupervised ML implementations, I highly recommend to follow the users, @jdehorty and @LuxAlgo
Optimizing the parameters:
Lookback Window (length): The lookback window determines how many previous bars are considered when calculating the kernel estimate.
For shorter-term trading strategies, you may want to use a shorter lookback window (e.g., 5-10).
For longer-term trading or investing, consider a longer lookback window (e.g., 20-50).
Relative Weight (relativeWeight): This parameter controls the importance of each data point in the calculation.
A higher relative weight (e.g., 2 or 3) emphasizes recent data, which can be suitable for trend-following strategies.
A lower relative weight (e.g., 1) gives more equal importance to historical and recent data, which may be useful for strategies that aim to capture both short-term and long-term trends.
ATR Length (atrLength): The length of the Average True Range (ATR) affects the width of the channels.
Longer ATR lengths result in wider channels, which may be suitable for capturing broader price movements.
Shorter ATR lengths result in narrower channels, which can be helpful for identifying smaller price swings.
Channel Multipliers (channelMultiplier1, channelMultiplier2, channelMultiplier3): These parameters determine the width of the channels relative to the ATR.
Adjust these multipliers based on your risk tolerance and desired channel width.
Higher multipliers result in wider channels, which may lead to fewer signals but potentially larger price movements.
Lower multipliers create narrower channels, which can result in more frequent signals but potentially smaller price movements.
Regression Line (Log)This indicator is based on the "Linear Regression Channel (Log)," which, in turn, is derived from TradingView's "Linear Regression Channel."
The "Regression Line (Log)" indicator is a valuable tool for traders and investors seeking to gain insights into long-term market trends. This indicator is personally favored for its ability to provide a comprehensive view of price movements over extended periods. It offers a unique perspective compared to traditional linear regression lines and moving averages, making it a valuable addition to the toolkit of experienced traders and investors.
Indicator Parameters:
Before delving into the details, it's worth noting that the chosen number of periods (2870) is a personal preference. This specific value is utilized for the S&P 500 index due to its alignment with various theories regarding the beginning of the modern economic era in the stock market. Different analysts propose different starting points, such as the 1950s, 1970s, or 1980s. However, users are encouraged to adjust this parameter to suit their specific needs and trading strategies.
How It Works:
The "Regression Line (Log)" indicator operates by transforming the closing price data into a logarithmic scale. This transformation can make the linear regression more suitable for data with exponential trends or rapid growth. Here's a breakdown of its functioning and why it can be advantageous for long-term trend analysis:
1. Logarithmic Transformation : The indicator begins by applying a logarithmic transformation to the closing price. This transformation helps capture price movements proportionally, making it especially useful for assets that exhibit exponential or rapid growth. This transformation can render linear regression more suitable for data with exponential or fast-paced trends.
2. Linear Regression on Log Scale : After the logarithmic transformation, the indicator calculates a linear regression line (lrc) on this log-transformed data. This step provides a smoother representation of long-term trends compared to a linear regression line on a linear scale.
3. Exponential Reversion : To present the results in a more familiar format, the indicator reverts the log-transformed regression line back to a linear scale using the math.exp function. This final output is the "Linear Regression Curve," which can be easily interpreted on standard price charts.
Advantages:
- Long-Term Trend Clarity : The logarithmic scale better highlights long-term trends and exponential price movements, making it a valuable tool for investors seeking to identify extended trends.
- Smoothing Effect : The logarithmic transformation and linear regression on a log scale smooth out price data, reducing noise and providing a clearer view of underlying trends.
- Adaptability : The indicator allows traders and investors to customize the number of periods (length) to align with their preferred historical perspective or trading strategy.
- Complementary to Other Tools : While not meant to replace other technical indicators, the "Regression Line (Log)" indicator complements traditional linear regression lines and moving averages, offering an alternative perspective for more comprehensive analysis.
Conclusion:
In summary, the "Regression Line (Log)" indicator is a versatile tool that can enhance your ability to analyze long-term market trends. Its logarithmic transformation provides a unique perspective on price data, particularly suited for assets with exponential growth patterns. While the choice of the number of periods is a personal one, it can be adapted to fit various historical viewpoints. This indicator is best utilized as part of a well-rounded trading strategy, in conjunction with other technical tools, to aid in informed decision-making.
Ticker Correlation Matrix Table and Heatmap [SS]Hello everyone,
I am in the process of releasing some of my own utility indicators/things I use to reference and perform analyses.
I do a lot of quantitative/math based analyses, including correlation assessments that I traditionally would need to export data from Tradingview and perform in SPSS, Excel or R. I have been slowly building a repertoire of Excel/R functionality right on pinescript so I do not need to constantly export data and can perform the assessments right on Tradingview.
This is an example of such an indicator.
About the Indicator:
It is a correlation table/matrix indicator. It will allow up to 10 ticker inputs, which can be stocks, economic data, anything available on Tradingview, and it will perform a correlation assessment in a matrix / heatmap style.
The indicator will show the various correlations among all of the selected ticker inputs and will colour them based on correlation strength and type.
Strong negative correlations will appear bright red.
Strong positive correlations will appear bright green.
Complete absence of correlation (i.e. 0) will show bright orange.
The rest will show a darker shade to indicate less strength/correlation.
Calculation Functions
In addition to outputting a correlation matrix, the indicator is also able to express the relationship between tickers in a linear expression using the y = mx + b formula.
If we look at table, we can see that MSFT and AAPL have a significantly strong correlation of 0.82.
If we wanted to express this relationship mathmatically, we can ask the indicator to represent the linear relationship in our y = mx + b format. We simply toggle to our menu and select the Convert From MSFT (Ticker 2) and convert to APPL (Ticker 3):
When we select this, a new table will populate below and give you the expression as well as the amount of error associated with it:
In this case, we can see that the equation is y = 0.553x + 0.626 with a range of around 10 points in either direction.
This means that, to convert MSFT to AAPL, we would multiply the MSFT price by 0.553 and then add 0.626. So if we try it, MSFT closed at 328.41. So we substitute:
AAPL price = 0.553(328.41) + 0.626
AAPL price = 181.61 + 0.626
AAPL Price = 182.24 +/- 10
AAPL actually closed at 184.12. So pretty good. If we try another, let's do SPY to XLF:
So we substitute, SPY closed at 449.16.
XLF Price = 449.16(0.077) + 0.084
XLF price = 34.59 + 0.084
XLF price = 34.67
XLF actually closed at 34.49.
This is handy if you want to see how one stock price may affect another. If you are long on one stock and short on another, you can use this to determine what the likely outcome may be for the alternative stock. However, I recommend only performing this on tickers that have a relationship of 0.7 or higher, or a relationship of -0.7 or lower.
I always had to use SPSS to do this, so being able to do this right in Pinescript for me is a huge convenience!
Some other uses:
As I tend to post educational stuff on Tradingview and I frequently use correlation matrices, I have formatted the indicator to be more aesthetically pleasing for these purposes. Thus, you can unselect extra ticker slots that you do not need. IF I only need to display 3 tickers, I can unselect tickers 4 - 10. The end result is a cleaner table:
Essential Functions:
The assessment length is defaulted to 75 candles on the daily timeframe. Be sure to have the daily timeframe opened when you are viewing the indicator.
You can increase or decrease the assessment length as you desire.
You can also specify the source. The source is defaulted to close, but if you want to see the direct correlation of ticker's highs and/or lows, you can modify the source input in the settings menu to look at this.
Just remember to have the chart opened to whatever timeframe you are looking at.
And that's the indicator! Hopefully you find it helpful. Its more of an academic indicator, but it is performing a function that I personally use frequently in analyses, so I hope you may also benefit from it as well!
Thanks for checking it out! Safe trades everyone!
Advanced Weighted Residual Arbitrage AnalyzerThe Advanced Weighted Residual Arbitrage Analyzer is a sophisticated tool designed for traders aiming to exploit price deviations between various asset pairs. By examining the differences in normalized price relations and their weighted residuals, this indicator provides insights into potential arbitrage opportunities in the market.
Key Features:
Multiple Relation Analysis: Analyze up to five different asset relations simultaneously, offering a comprehensive view of potential arbitrage setups.
Normalization Functions: Choose from a variety of normalization techniques like SMA, EMA, WMA, and HMA to ensure accurate comparisons between different price series.
Dynamic Weighting: Residuals are weighted based on their correlation, ensuring that stronger correlations have a more pronounced impact on the analysis. Weighting can be adjusted using several functions including square, sigmoid, and logistic.
Regression Flexibility: Incorporate linear, polynomial, or robust regression to calculate residuals, tailoring the analysis to different market conditions.
Customizable Display: Decide which plots to display for clarity and focus, including normalized relations, weighted residuals, and the difference between the screen relation and the average weighted residual.
Usage Guidelines:
Configure the asset pairs you wish to analyze using the Symbol Relations group in the settings.
Adjust the normalization, volatility, regression, and weighting functions based on your preference and the specific characteristics of the asset pairs.
Monitor the weighted residuals for deviations from the mean. Larger deviations suggest stronger arbitrage opportunities.
Use the difference plot (between the screen relation and average weighted residual) as a quick visual cue for potential trade setups. When this plot deviates significantly from zero, it indicates a possible arbitrage opportunity.
Regularly update and adjust the parameters to account for changing market conditions and ensure the most accurate analysis.
In the Advanced Weighted Residual Arbitrage Analyzer , the value set in Alert Threshold plays a crucial role in delineating a normalized band. This band serves as a guide to identify significant deviations and potential trading opportunities.
When we observe the plots of the green line and the purple line, the Alert Threshold provides a boundary for these plots. The following points explain the significance:
Breach of the Band: When either the green or purple line crosses above or below the Alert Threshold , it indicates a significant deviation from the mean. This breach can be interpreted as a potential trading signal, suggesting a possible arbitrage opportunity.
Convergence to the Mean: If the green line converges with the purple line , it denotes that the price relation has reverted to its mean. This convergence typically suggests that the arbitrage opportunity has been exhausted, and the market dynamics are returning to equilibrium.
Trade Execution: A trader can consider entering a trade when the lines breach the Alert Threshold . The return of the green line to align closely with the purple line can be seen as a signal to exit the trade, capitalizing on the reversion to the mean.
By monitoring these plots in conjunction with the Alert Threshold , traders can gain insights into market imbalances and exploit potential arbitrage opportunities. The convergence and divergence of these lines, relative to the normalized band, serve as valuable visual cues for trade initiation and termination.
When you're analyzing relations between two symbols (for instance, BINANCE:SANDUSDT/BINANCE:NEARUSDT ), you're essentially looking at the price relationship between the two underlying assets. This relationship provides insights into potential imbalances between the assets, which arbitrage traders can exploit.
Breach of the Lower Band: If the purple line touches or crosses below the lower Alert Threshold , it indicates that the first symbol (in our example, SANDUSDT ) is undervalued relative to the second symbol ( NEARUSDT ). In practical terms:
Action: You would consider buying the first symbol ( SANDUSDT ) and selling the second symbol ( NEARUSDT ).
Rationale: The expectation is that the price of the first symbol will rise, or the price of the second symbol will fall, or both, thereby converging back to their historical mean relationship.
Breach of the Upper Band: Conversely, if the difference plot touches or crosses above the upper Alert Threshold , it suggests that the first symbol is overvalued compared to the second. This implies:
Action: You'd consider selling the first symbol ( SANDUSDT ) and buying the second symbol ( NEARUSDT ).
Rationale: The anticipation here is that the price of the first symbol will decrease, or the price of the second will increase, or both, bringing the relationship back to its historical average.
Convergence to the Mean: As mentioned earlier, when the green line aligns closely with the purple line, it's an indication that the assets have returned to their typical price relationship. This serves as a signal for traders to consider closing out their positions, locking in the gains from the arbitrage opportunity.
It's important to note that when you're trading based on symbol relations, you're essentially betting on the relative performance of the two assets. This strategy, often referred to as "pairs trading," seeks to capitalize on price imbalances between related financial instruments. By taking opposing positions in the two symbols, traders aim to profit from the eventual reversion of the price difference to the mean.
Machine Learning Regression Trend [LuxAlgo]The Machine Learning Regression Trend tool uses random sample consensus (RANSAC) to fit and extrapolate a linear model by discarding potential outliers, resulting in a more robust fit.
🔶 USAGE
The proposed tool can be used like a regular linear regression, providing support/resistance as well as forecasting an estimated underlying trend.
Using RANSAC allows filtering out outliers from the input data of our final fit, by outliers we are referring to values deviating from the underlying trend whose influence on a fitted model is undesired. For financial prices and under the assumptions of segmented linear trends, these outliers can be caused by volatile moves and/or periodic variations within an underlying trend.
Adjusting the "Allowed Error" numerical setting will determine how sensitive the model is to outliers, with higher values returning a more sensitive model. The blue margin displayed shows the allowed error area.
The number of outliers in the calculation window (represented by red dots) can also be indicative of the amount of noise added to an underlying linear trend in the price, with more outliers suggesting more noise.
Compared to a regular linear regression which does not discriminate against any point in the calculation window, we see that the model using RANSAC is more conservative, giving more importance to detecting a higher number of inliners.
🔶 DETAILS
RANSAC is a general approach to fitting more robust models in the presence of outliers in a dataset and as such does not limit itself to a linear regression model.
This iterative approach can be summarized as follow for the case of our script:
Step 1: Obtain a subset of our dataset by randomly selecting 2 unique samples
Step 2: Fit a linear regression to our subset
Step 3: Get the error between the value within our dataset and the fitted model at time t , if the absolute error is lower than our tolerance threshold then that value is an inlier
Step 4: If the amount of detected inliers is greater than a user-set amount save the model
Repeat steps 1 to 4 until the set number of iterations is reached and use the model that maximizes the number of inliers
🔶 SETTINGS
Length: Calculation window of the linear regression.
Width: Linear regression channel width.
Source: Input data for the linear regression calculation.
🔹 RANSAC
Minimum Inliers: Minimum number of inliers required to return an appropriate model.
Allowed Error: Determine the tolerance threshold used to detect potential inliers. "Auto" will automatically determine the tolerance threshold and will allow the user to multiply it through the numerical input setting at the side. "Fixed" will use the user-set value as the tolerance threshold.
Maximum Iterations Steps: Maximum number of allowed iterations.
AI Moving Average (Expo)█ Overview
The AI Moving Average indicator is a trading tool that uses an AI-based K-nearest neighbors (KNN) algorithm to analyze and interpret patterns in price data. It combines the logic of a traditional moving average with artificial intelligence, creating an adaptive and robust indicator that can identify strong trends and key market levels.
█ How It Works
The algorithm collects data points and applies a KNN-weighted approach to classify price movement as either bullish or bearish. For each data point, the algorithm checks if the price is above or below the calculated moving average. If the price is above the moving average, it's labeled as bullish (1), and if it's below, it's labeled as bearish (0). The K-Nearest Neighbors (KNN) is an instance-based learning algorithm used in classification and regression tasks. It works on a principle of voting, where a new data point is classified based on the majority label of its 'k' nearest neighbors.
The algorithm's use of a KNN-weighted approach adds a layer of intelligence to the traditional moving average analysis. By considering not just the price relative to a moving average but also taking into account the relationships and similarities between different data points, it offers a nuanced and robust classification of price movements.
This combination of data collection, labeling, and KNN-weighted classification turns the AI Moving Average (Expo) Indicator into a dynamic tool that can adapt to changing market conditions, making it suitable for various trading strategies and market environments.
█ How to Use
Dynamic Trend Recognition
The color-coded moving average line helps traders quickly identify market trends. Green represents bullish, red for bearish, and blue for neutrality.
Trend Strength
By adjusting certain settings within the AI Moving Average (Expo) Indicator, such as using a higher 'k' value and increasing the number of data points, traders can gain real-time insights into strong trends. A higher 'k' value makes the prediction model more resilient to noise, emphasizing pronounced trends, while more data points provide a comprehensive view of the market direction. Together, these adjustments enable the indicator to display only robust trends on the chart, allowing traders to focus exclusively on significant market movements and strong trends.
Key SR Levels
Traders can utilize the indicator to identify key support and resistance levels that are derived from the prevailing trend movement. The derived support and resistance levels are not just based on historical data but are dynamically adjusted with the current trend, making them highly responsive to market changes.
█ Settings
k (Neighbors): Number of neighbors in the KNN algorithm. Increasing 'k' makes predictions more resilient to noise but may decrease sensitivity to local variations.
n (DataPoints): Number of data points considered in AI analysis. This affects how the AI interprets patterns in the price data.
maType (Select MA): Type of moving average applied. Options allow for different smoothing techniques to emphasize or dampen aspects of price movement.
length: Length of the moving average. A greater length creates a smoother curve but might lag recent price changes.
dataToClassify: Source data for classifying price as bullish or bearish. It can be adjusted to consider different aspects of price information
dataForMovingAverage: Source data for calculating the moving average. Different selections may emphasize different aspects of price movement.
-----------------
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!
AI Trend Navigator [K-Neighbor]█ Overview
In the evolving landscape of trading and investment, the demand for sophisticated and reliable tools is ever-growing. The AI Trend Navigator is an indicator designed to meet this demand, providing valuable insights into market trends and potential future price movements. The AI Trend Navigator indicator is designed to predict market trends using the k-Nearest Neighbors (KNN) classifier.
By intelligently analyzing recent price actions and emphasizing similar values, it helps traders to navigate complex market conditions with confidence. It provides an advanced way to analyze trends, offering potentially more accurate predictions compared to simpler trend-following methods.
█ Calculations
KNN Moving Average Calculation: The core of the algorithm is a KNN Moving Average that computes the mean of the 'k' closest values to a target within a specified window size. It does this by iterating through the window, calculating the absolute differences between the target and each value, and then finding the mean of the closest values. The target and value are selected based on user preferences (e.g., using the VWAP or Volatility as a target).
KNN Classifier Function: This function applies the k-nearest neighbor algorithm to classify the price action into positive, negative, or neutral trends. It looks at the nearest 'k' bars, calculates the Euclidean distance between them, and categorizes them based on the relative movement. It then returns the prediction based on the highest count of positive, negative, or neutral categories.
█ How to use
Traders can use this indicator to identify potential trend directions in different markets.
Spotting Trends: Traders can use the KNN Moving Average to identify the underlying trend of an asset. By focusing on the k closest values, this component of the indicator offers a clearer view of the trend direction, filtering out market noise.
Trend Confirmation: The KNN Classifier component can confirm existing trends by predicting the future price direction. By aligning predictions with current trends, traders can gain more confidence in their trading decisions.
█ Settings
PriceValue: This determines the type of price input used for distance calculation in the KNN algorithm.
hl2: Uses the average of the high and low prices.
VWAP: Uses the Volume Weighted Average Price.
VWAP: Uses the Volume Weighted Average Price.
Effect: Changing this input will modify the reference values used in the KNN classification, potentially altering the predictions.
TargetValue: This sets the target variable that the KNN classification will attempt to predict.
Price Action: Uses the moving average of the closing price.
VWAP: Uses the Volume Weighted Average Price.
Volatility: Uses the Average True Range (ATR).
Effect: Selecting different targets will affect what the KNN is trying to predict, altering the nature and intent of the predictions.
Number of Closest Values: Defines how many closest values will be considered when calculating the mean for the KNN Moving Average.
Effect: Increasing this value makes the algorithm consider more nearest neighbors, smoothing the indicator and potentially making it less reactive. Decreasing this value may make the indicator more sensitive but possibly more prone to noise.
Neighbors: This sets the number of neighbors that will be considered for the KNN Classifier part of the algorithm.
Effect: Adjusting the number of neighbors affects the sensitivity and smoothness of the KNN classifier.
Smoothing Period: Defines the smoothing period for the moving average used in the KNN classifier.
Effect: Increasing this value would make the KNN Moving Average smoother, potentially reducing noise. Decreasing it would make the indicator more reactive but possibly more prone to false signals.
█ What is K-Nearest Neighbors (K-NN) algorithm?
At its core, the K-NN algorithm recognizes patterns within market data and analyzes the relationships and similarities between data points. By considering the 'K' most similar instances (or neighbors) within a dataset, it predicts future price movements based on historical trends. The K-Nearest Neighbors (K-NN) algorithm is a type of instance-based or non-generalizing learning. While K-NN is considered a relatively simple machine-learning technique, it falls under the AI umbrella.
We can classify the K-Nearest Neighbors (K-NN) algorithm as a form of artificial intelligence (AI), and here's why:
Machine Learning Component: K-NN is a type of machine learning algorithm, and machine learning is a subset of AI. Machine learning is about building algorithms that allow computers to learn from and make predictions or decisions based on data. Since K-NN falls under this category, it is aligned with the principles of AI.
Instance-Based Learning: K-NN is an instance-based learning algorithm. This means that it makes decisions based on the entire training dataset rather than deriving a discriminative function from the dataset. It looks at the 'K' most similar instances (neighbors) when making a prediction, hence adapting to new information if the dataset changes. This adaptability is a hallmark of intelligent systems.
Pattern Recognition: The core of K-NN's functionality is recognizing patterns within data. It identifies relationships and similarities between data points, something akin to human pattern recognition, a key aspect of intelligence.
Classification and Regression: K-NN can be used for both classification and regression tasks, two fundamental problems in machine learning and AI. The indicator code is used for trend classification, a predictive task that aligns with the goals of AI.
Simplicity Doesn't Exclude AI: While K-NN is often considered a simpler algorithm compared to deep learning models, simplicity does not exclude something from being AI. Many AI systems are built on simple rules and can be combined or scaled to create complex behavior.
No Explicit Model Building: Unlike traditional statistical methods, K-NN does not build an explicit model during training. Instead, it waits until a prediction is required and then looks at the 'K' nearest neighbors from the training data to make that prediction. This lazy learning approach is another aspect of machine learning, part of the broader AI field.
-----------------
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!
Extrapolated Previous Trend [LuxAlgo]The Extrapolated Previous Trend indicator extrapolates the estimated linear trend of the prices within a previous interval to the current interval. Intervals can be user-defined.
🔶 USAGE
Returned lines can be used to provide a forecast of trends, assuming trends are persistent in sign and slope.
Using them as support/resistance can also be an effecting usage in case the trend in a new interval does not follow the characteristic of the trend in the previous interval.
The indicator includes a dashboard showing the degree of persistence between segmented trends for uptrends and downtrends. A higher value is indicative of more persistent trend signs.
A lower value could hint at an anti-persistent behavior, with uptrends over an interval often being followed by a down-trend and vice versa. We can invert candle colors to determine future trend direction in this case.
🔶 DETAILS
This indicator can be thought of as a segmented linear model ( a(n)t + b(n) ), where n is the specific interval index. Unlike a regular segmented linear regression model, this indicator is not subject to lookahead bias, coefficients of the model are obtained on previous intervals.
The quality of the fit of the model is dependent on the variability of its coefficients a(n) and b(n) . Coefficients being less subject to change over time are more indicative of trend persistence.
🔶 SETTINGS
Timeframe: Determine the frequency at which new trends are estimated.
Open Price Regression Modelnput Variables: The user can adjust the lookbackPeriod and m (multiplier) inputs. The lookbackPeriod specifies the number of previous bars used for regression calculations, and m is used to calculate the confidence interval width.
Calculate Regression Model: The code extracts open, high, low, and close prices for the current candle. It then performs regression calculations for high, low, and close prices based on the open prices.
Calculate Predicted Prices: Using the regression coefficients and intercepts, the code calculates predicted high, low, and close prices based on the current open price.
Calculate Confidence Interval: The code computes the standard errors of the regression for high, low, and close prices and multiplies them by the specified confidence level multiplier (m) to determine the width of the confidence intervals.
Plotting: The predicted high, low, and close prices are plotted with different colors. Additionally, confidence intervals are plotted around the predicted prices using lines.
Implications and Trading Advantage:
The Open Price Regression Model aims to predict future high, low, and close prices based on the current open price. Traders can use the predicted values and confidence intervals as potential price targets and volatility measures. Traders can consider taking long or short positions based on whether the current open price is below or above the predicted prices. Can be used on a daily time frame to forecast the day's high and low and use this levels are horizontal price levels on lower timeframes.
Top - Bottom Using MAThis script is used decide weather stock is overbought or oversold in given length/days from the settings.
using close difference from ohlc4 moving average ratio.
Settings Available
1) moving average length
2) Highest / Lowest ratio length
3) Difference Between Highest and Lowest Line
this script plot/display 4 lines
1) highest difference from moving averages in provided length.
2) lowest difference from moving averages in provided length.
3) ratio of moving average and ohlc4
4) linear regression moving averages of ratio of moving average and ohlc4
How to use this script
1) when ratio line is touch 2 days to highest ratio line means we are consider stock is in overbought levels or linear regression moving average above highest ratio line means overbought.
2) when ratio lines cross below its linear regression moving average then we consider final exit or book profit.
3) when linear regression moving average below lowest ratio line means stock is in oversold.
4) when linear regression moving average below lowest ratio line and linear regression line start rising after fall it means there is change in trend.
5) when linear regression moving average cross above lowest ratio line it means trend is changed and linear regression line turns green.
Multi Kernel Regression [ChartPrime]The "Multi Kernel Regression" is a versatile trading indicator that provides graphical interpretations of market trends by using different kernel regression methods. It's beneficial because it smoothes out price data, creating a clearer picture of price movements, and can be tailored according to the user's preference with various options.
What makes this indicator uniquely versatile is the 'Kernel Select' feature, which allows you to choose from a variety of regression kernel types, such as Gaussian, Logistic, Cosine, and many more. In fact, you have 17 options in total, making this an adaptable tool for diverse market contexts.
The bandwidth input parameter directly affects the smoothness of the regression line. While a lower value will make the line more sensitive to price changes by sticking closely to the actual prices, a higher value will smooth out the line even further by placing more emphasis on distant prices.
It's worth noting that the indicator's 'Repaint' function, which re-estimates work according to the most recent data, is not a deficiency or a flaw. Instead, it’s a crucial part of its functionality, updating the regression line with the most recent data, ensuring the indicator measurements remain as accurate as possible. We have however included a non-repaint feature that provides fixed calculations, creating a steady line that does not change once it has been plotted, for a different perspective on market trends.
This indicator also allows you to customize the line color, style, and width, allowing you to seamlessly integrate it into your existing chart setup. With labels indicating potential market turn points, you can stay on top of significant price movements.
Repaint : Enabling this allows the estimator to repaint to maintain accuracy as new data comes in.
Kernel Select : This option allows you to select from an array of kernel types such as Triangular, Gaussian, Logistic, etc. Each kernel has a unique weight function which influences how the regression line is calculated.
Bandwidth : This input, a scalar value, controls the regression line's sensitivity towards the price changes. A lower value makes the regression line more sensitive (closer to price) and higher value makes it smoother.
Source : Here you denote which price the indicator should consider for calculation. Traditionally, this is set as the close price.
Deviation : Adjust this to change the distance of the channel from the regression line. Higher values widen the channel, lower values make it smaller.
Line Style : This provides options to adjust the visual style of the regression lines. Options include Solid, Dotted, and Dashed.
Labels : Enabling this introduces markers at points where the market direction switches. Adjust the label size to suit your preference.
Colors : Customize color schemes for bullish and bearish trends along with the text color to match your chart setup.
Kernel regression, the technique behind the Multi Kernel Regression Indicator, has a rich history rooted in the world of statistical analysis and machine learning.
The origins of kernel regression are linked to the work of Emanuel Parzen in the 1960s. He was a pioneer in the development of nonparametric statistics, a domain where kernel regression plays a critical role. Although originally developed for the field of probability, these methods quickly found application in various other scientific disciplines, notably in econometrics and finance.
Kernel regression became really popular in the 1980s and 1990s along with the rise of other nonparametric techniques, like local regression and spline smoothing. It was during this time that kernel regression methods were extensively studied and widely applied in the fields of machine learning and data science.
What makes the kernel regression ideal for various statistical tasks, including financial market analysis, is its flexibility. Unlike linear regression, which assumes a specific functional form for the relationship between the independent and dependent variables, kernel regression makes no such assumptions. It creates a smooth curve fit to the data, which makes it extremely useful in capturing complex relationships in data.
In the context of stock market analysis, kernel regression techniques came into use in the late 20th century as computational power improved and these techniques could be more easily applied. Since then, they have played a fundamental role in financial market modeling, market prediction, and the development of trading indicators, like the Multi Kernel Regression Indicator.
Today, the use of kernel regression has solidified its place in the world of trading and market analysis, being widely recognized as one of the most effective methods for capturing and visualizing market trends.
The Multi Kernel Regression Indicator is built upon kernel regression, a versatile statistical method pioneered by Emanuel Parzen in the 1960s and subsequently refined for financial market analysis. It provides a robust and flexible approach to capturing complex market data relationships.
This indicator is more than just a charting tool; it reflects the power of computational trading methods, combining statistical robustness with visual versatility. It's an invaluable asset for traders, capturing and interpreting complex market trends while integrating seamlessly into diverse trading scenarios.
In summary, the Multi Kernel Regression Indicator stands as a testament to kernel regression's historic legacy, modern computational power, and contemporary trading insight.
Intraday trading period indicatorI have created this indicator because I was in a need of simple indication of personal session time for my backtesting while practicing intraday Futures trading.
How it works:
1. Define your timezone.
2. Set Trading session start/end time.
3. Choose the colour you want to see your intraday session in.
Actual result: Your selected session is displayed with selected colour and within selected time period. Your are good to go.
It is not perfect for sure but it does what it needs to do and I think it is awesome.
Hope it will be useful for you and let the Profit be with you!
Regression Candle Conversion IndicatorHey everyone!
I got a pseudo-request a while ago for something like this, essentially the ability to track where another ticker would fall based on an alternative ticker.
I did create my ticker correlation reference indicator which directly looks at the correlation between 2 tickers. However, this is an indicator that operates on the same principle but is more pragmatic for trading.
What does it do?
Well, in keeping with the theme of what I call my indicators, this has a title that explains exactly what it does, "Regression Candle Conversion Indicator" or "RCCI" for short. It uses simple regression to convert one ticker to another. So while you are tracking one indicator, you can see where the expected value should fall on the other.
Applications?
The big application of this for me is being able to track where SPY/QQQ or IWM is falling during overnight trading sessions. Extended trading hours close at 8 pm NYSE time. After that, you have to guess where futures prices will put the ETF version of it. This indicator will allow you to track where, theoretically, the underlying ETF ticker will fall based on the current trading behaviour.
Some other applications are just the ability to track how similar or dissimilar one stock is to the other. For example, if we wanted to trade, say, Boeing using shares of DFEN or ITA (a defence specific ETF), here is what we get:
In the chart above we can see BA as the primary chart and ITA as the RCCI converted chart. We will see 2 major things that should cause us concern.
First, there is a really poor correlation between the two tickers. This indicates that ITA may not produce the best exposure if I am directly looking for Boeing exposure.
Second, there is a wide standard error. this means that the results that the RCCI is providing may be skewed up to +/- 2 points (as indicated by the standard error chart).
Let's take a look at BA and DFEN:
In the above, we can see that the correlation is not great, but the standard error is quite low.
This means that, while this may not be the best ticker for Boeing exposure, the RCCI is able to confidently calculate the ticker within +/- 0.50 cents based on BA's underlying data.
However, its important to note that it is not advisable to really rely on these results if the correlation is less than + 0.5 or greater than -0.5.
Let's take a look at a few more examples:
Above we have BA (NYSE) vs BA (NEO TSX CAD Hedged). We can see the strong relationship and high confidence calculations.
And some others:
SPX (primary) and ES1! (secondary):
RTY and IWM:
ES1! and SPY:
Customizations:
As you can see above, it is pretty straight forward. There are 3 options:
Lookback Length: Determines the length of assessment for correlation and the regression assessment.
Manual Ticker Input: The indicator will pull the data from your current chart and compare it against a manually selected indicator. You must tell the indicator which ticker you are comparing against.
Data Table: This will show you the data table which contains the standard error assessment and the correlation assessment. These are determined by your lookback length. The lookback length is defaulted to 500.
And that's the indicator! It's pretty straight forward. Hopefully you find it helpful, especially if you track futures during overnight sessions.
Leave your comments/questions and feedback below.
Thanks for checking it out!
Visible Range Linear Regression Channel [vnhilton](OVERVIEW)
This indicator calculates the linear regression channel for the visible bars shown on the chart instead of the traditional fixed length linear regression channel TradingView provides (and is more accurate I believe). Inspired by TradingView's Linear Regression Channel and Visible Average Price indicator, and the DAS Trader linear regression indicator.
(FEATURES)
- Ability to extend lines to the right
- Show/hide individual lines
- Adjust standard deviation of bands
- Adjust line style and width of basis and band lines
- Change individual line colours and plot fills between the lines
(DIFFERENCES)
If you compare this indicator to TradingView's Linear Regression Channel, you will notice some differences (as of 11th June, 2023). Differences and reasons are:
1) The intercept is wrong. The formula TradingView uses to calculate the intercept includes the addition of the gradient, which I believe is incorrect. Difference #2 is also why the intercept is wrong. This indicator omits that addition. This was verified by comparing the gradient calculated in this indicator with the gradient determined by Excel with the same data.
2) The gradient is "wrong". In quotations as essentially TradingView's code attempts to find the line of best fit, with the y-axis on the most recent bar instead of the oldest bar. This leads to the gradient being the opposite to the gradient found in this indicator, which isn't wrong, but the later formula used to calculate the intercept doesn't take this into account, resulting in an incorrect intercept value. The gradient and intercept values in this indicator matches those found in Excel.
3) Standard deviation bands of both indicators. I believe the code TradingView uses to calculate standard deviation is incorrect (basing this just through visuals). This indicator uses the array.stdev function to find the correct value (verified with Excel numbers).
Trend Finder++ (by Alex L.)This indicator seeks for a short term trend within a bigger long term trend and displays both in a channel with an extension lines (optional).
Use of this indicator is quite simple: when the stock is near the trend line bottom (default RED) it can be a good time to buy and when the stock is near the trend line top (default GREEN) it can be a good time to sell.
What new ideas and cool stuff this indicator offers:
- 'Trend (Months)' -
Trend channels will always be displayed over the period: last 'X' months (regardless of the 'Time Interval' set in your chart)
This allows you to go into a larger or smaller resolution and still see the same trend lines!
- ' Trend (Bars)' -
Optional. You can choose to display the Trend channel based on bars instead of months.
This can be useful for advanced traders, or in case a security is new and there isn't even 1 month of data.
- 'Show long-term trend' -
Optional. Displays a larger 3rd (even more long-term) trend in addition to the two current trends.
This is for advanced traders who want to see an even more bigger picture. It is best viewed on a weekly time interval.
- Customizable channel size, channel colors and channel style.
- 'Extend lines' -
Optional (default: yes). Trend channels' can be displayed with extension or without using this option.
- Internal Feature -
When trend channel goes below zero (can happen if stock's price falls sharply) - its below-zero portion will be drawn as 'extension' instead.
This is useful if such occurs, and we're in an auto-scaled chart - the lines will take less space on screen (for cleaner view).
Based on an idea/indicator by @ DevLucem called "Linear Regression ++"
Open Source.
Enjoy!
Kernel Regression ToolkitThis toolkit provides filters and extra functionality for non-repainting Nadaraya-Watson estimator implementations made by @jdehorty. For the sake of ease I have nicknamed it "kreg". Filters include a smoothing formula and zero lag formula. The purpose of this script is to help traders test, experiment and develop different regression lines. Regression lines are best used as trend lines and can be an invaluable asset for quickly locating first pullbacks and breaks of trends.
Other features include two J lines and a blend line. J lines are featured in tools like Stochastic KDJ. The formula uses the distance between K and D lines to make the J line. The blend line adds the ability to blend two lines together. This can be useful for several tasks including finding a center/median line between two lines or for blending in the characteristics of a different line. Default is set to 50 which is a 50% blend of the two lines. This can be increased and decreased to taste. This tool can be overlaid on the chart or on top of another indicator if you set the source. It can even be moved into its own window to create a unique oscillator based on whatever sources you feed it.
Below are the standard settings for the kernel estimation as documented by @jdehorty:
Lookback Window: The number of bars used for the estimation. This is a sliding value that represents the most recent historical bars. Recommended range: 3-50
Weighting: Relative weighting of time frames. As this value approaches zero, the longer time frames will exert more influence on the estimation. As this value approaches infinity, the behavior of the Rational Quadratic Kernel will become identical to the Gaussian kernel. Recommended range: 0.25-25
Level: Bar index on which to start regression. Controls how tightly fit the kernel estimate is to the data. Smaller values are a tighter fit. Larger values are a looser fit. Recommended range: 2-25
Lag: Lag for crossover detection. Lower values result in earlier crossovers. Recommended range: 1-2
For more information on this technique refer to to the original open source indicator by @jdehorty located here:
Nonlinear Regression, Zero-lag Moving Average [Loxx]Nonlinear Regression and Zero-lag Moving Average
Technical indicators are widely used in financial markets to analyze price data and make informed trading decisions. This indicator presents an implementation of two popular indicators: Nonlinear Regression and Zero-lag Moving Average (ZLMA). Let's explore the functioning of these indicators and discuss their significance in technical analysis.
Nonlinear Regression
The Nonlinear Regression indicator aims to fit a nonlinear curve to a given set of data points. It calculates the best-fit curve by minimizing the sum of squared errors between the actual data points and the predicted values on the curve. The curve is determined by solving a system of equations derived from the data points.
We define a function "nonLinearRegression" that takes two parameters: "src" (the input data series) and "per" (the period over which the regression is calculated). It calculates the coefficients of the nonlinear curve using the least squares method and returns the predicted value for the current period. The nonlinear regression curve provides insights into the overall trend and potential reversals in the price data.
Zero-lag Moving Average (ZLMA)
Moving averages are widely used to smoothen price data and identify trend directions. However, traditional moving averages introduce a lag due to the inclusion of past data. The Zero-lag Moving Average (ZLMA) overcomes this lag by dynamically adjusting the weights of past values, resulting in a more responsive moving average.
We create a function named "zlma" that calculates the ZLMA. It takes two parameters: "src" (the input data series) and "per" (the period over which the ZLMA is calculated). The ZLMA is computed by first calculating a weighted moving average (LWMA) using a linearly decreasing weight scheme. The LWMA is then used to calculate the ZLMA by applying the same weight scheme again. The ZLMA provides a smoother representation of the price data while reducing lag.
Combining Nonlinear Regression and ZLMA
The ZLMA is applied to the input data series using the function "zlma(src, zlmaper)". The ZLMA values are then passed as input to the "nonLinearRegression" function, along with the specified period for nonlinear regression. The output of the nonlinear regression is stored in the variable "out".
To enhance the visual representation of the indicator, colors are assigned based on the relationship between the nonlinear regression value and a signal value (sig) calculated from the previous period's nonlinear regression value. If the current "out" value is greater than the previous "sig" value, the color is set to green; otherwise, it is set to red.
The indicator also includes optional features such as coloring the bars based on the indicator's values and displaying signals for potential long and short positions. The signals are generated based on the crossover and crossunder of the "out" and "sig" values.
Wrapping Up
This indicator combines two important concepts: Nonlinear Regression and Zero-lag Moving Average indicators, which are valuable tools for technical analysis in financial markets. These indicators help traders identify trends, potential reversals, and generate trading signals. By combining the nonlinear regression curve with the zero-lag moving average, this indicator provides a comprehensive view of the price dynamics. Traders can customize the indicator's settings and use it in conjunction with other analysis techniques to make well-informed trading decisions.
Time Series Model IndicatorHello,
I am releasing this time series modelling indicator.
Brief overview of the indicator's functionality:
The Time Series Model indicator is a technical analysis tool that calculates and visualizes a linear regression line based on historical price data. It assesses the trend direction and provides an outer band around the regression line to indicate potential support and resistance levels. The indicator also detects outliers in the price data and calculates correlations between the time variable and the closing price. It offers various customization options such as input length, user-defined hours in advance, display settings for tables and fills, and the ability to show variable correlations. Overall, this indicator aims to help traders identify trends, potential reversals, and price extremes in a given time series.
Specific Functions:
Slope Calculations: The indicator calculates the slope and intercept of the regression line using the specified length of assessment (user defined). It also computes the residuals, standard error of the regression, and the upper and lower bounds of the standard error region. Additionally, it calculates multiple standard deviation bands around the regression line. The slope will change to green if the stock is in an uptrend and to red if the stock is in a downtrend.
Outliers: This feature detects extreme positive and negative outliers based on the z-score calculated from the price data. It highlights the outliers with a red background color to red if this option is selected.
Correlation to Time Assessments: This feature performs trend assessments based on the correlation between time and price data. It identifies uptrends, downtrends, falling trends, rising trends, etc.
Outerband Plots: This feature plots the regression line, standard error bands, and multiple standard deviation bands around the regression line. It also fills the areas between these lines.
Trend Assessment: This feature further assesses the trend based on the strength of the correlation. It identifies strong up or down trends, moderate trends, weak trends, no trend, etc.
Linear Regression Time Data: This section retrieves price data (close, high, low, open) for the specified timeframe and stores them in arrays for a linear regression analysis.
Define LinReg Variables: This section calculates linear regression lines and their upper and lower control limits for the close, low and high prices. It also calculates the correlation between close price and time.
Manual assessments: This feature allows for the manual assessment of time series data. The user can input a look forward for hours in the future and get the predicted price range based on the current time relationship. See image below:
Calculating model "fit": The indicator will display the amount of time the stock closes within and outside its respective bands to ascertain the degree of "fit" (see image below):
Explanations:
The outer cloud: The outer, tealish green cloud represents the regression line + 1.5 standard deviations from the regression line.
The inner cloud: The inner, white coloured cloud represents the immediate time series range calculated through regression of the open, high and low price of the ticker.
Correlations:
The ability of the indicator to calculate correlations on both the smaller and larger timeframes are its strongest feature. You can see the formation of trends by tracking the correlation over the length of the time series model's assessment. You can also track the degree of change. The image below shows the correlation table:
In this image, we can see that the stock is in a moderate downtrend manifested by a correlation of -0.73 (purple arrow).
This downtrend is weakening as manifested by a positive change of 0.05 on the shorter timeframe.
If we scroll down on the table and see the Close, High and Low, we can see that the larger trend over time is a downtrend and that this downtrend is actually strengthening. We know this by the negative change (negative change = significant inverse relationship to time is increasing. i.e. as time increases, the stock price decreases proportionately).
So what does negative correlation to time mean?
If a stock's price exhibits a negative correlation to time, it implies that there is a systematic relationship between the passage of time and the stock's price movement in the opposite direction. This finding could have several potential implications for traders and investors. Firstly, it suggests that the stock's price tends to decrease as time progresses, indicating a downward trend or bearish sentiment. This information might be useful for traders looking to capitalize on short-selling or hedging strategies. Secondly, it could indicate a potential opportunity to predict future price movements based on the timing of negative correlations. By understanding the relationship between time and price, investors may be able to make more informed decisions about when to buy or sell the stock. Lastly, a negative correlation to time may also suggest the influence of external factors or market conditions that systematically impact the stock's performance over time. Therefore, monitoring this correlation can provide insights into broader market dynamics and help investors better understand the stock's behavior.
What about a positive correlation to time?
If a stock's price demonstrates a positive correlation to time, it means that there is a consistent relationship between the passage of time and the stock's price movement in the same direction. This positive correlation to time can have significant implications for traders and investors. Firstly, it indicates a potential upward trend or bullish sentiment, suggesting that the stock's price tends to increase as time progresses. This information can be valuable for investors seeking long-term growth opportunities or looking to capitalize on upward price movements. Secondly, a positive correlation to time may provide insights into the stock's historical performance patterns and help identify potential buying or selling opportunities based on the timing of positive correlations. Additionally, understanding this correlation can aid in assessing the stock's overall trajectory and identifying potential market trends. It's important to note that positive correlation to time does not guarantee future performance, but it can offer valuable information to inform investment decisions.
Because this indicator is pretty big, I have done an overview and tutorial video which I will link below:
As always, please leave your comments and suggestions below.
I thank you for taking the time to read and check out this indicator.
Safe trades everyone and enjoy your weekend!
Linear Regression Channel (Log)The Linear Regression Channel (Log) indicator is a modified version of the Linear Regression channel available on TradingView. It is designed to be used on a logarithmic scale, providing a different perspective on price movements.
The indicator utilizes the concept of linear regression to visualize the overall price trend in a specific section of the chart. The central line represents the linear regression calculation, while the upper and lower lines indicate a certain number of standard deviations away from the central line. These bands serve as support and resistance levels, and when prices remain outside the channel for an extended period, a potential reversal may be anticipated.
I have replaced the Pearson values with trend strength levels to enhance understanding for individuals unfamiliar with Pearson correlation.
Auto Trend ProjectionAuto Trend Projection is an indicator designed to automatically project the short-term trend based on historical price data. It utilizes a dynamic calculation method to determine the slope of the linear regression line, which represents the trend direction. The indicator takes into account multiple length inputs and calculates the deviation and Pearson's R values for each length.
Using the highest Pearson's R value, Auto Trend Projection identifies the optimal length for the trend projection. This ensures that the projected trend aligns closely with the historical price data.
The indicator visually displays the projected trend using trendlines. These trendlines extend into the future, providing a visual representation of the potential price movement in the short term. The color and style of the trendlines can be customized according to user preferences.
Auto Trend Projection simplifies the process of trend analysis by automating the projection of short-term trends. Traders and investors can use this indicator to gain insights into potential price movements and make informed trading decisions.
Please note that Auto Trend Projection is not a standalone trading strategy but a tool to assist in trend analysis. It is recommended to combine it with other technical analysis tools and indicators for comprehensive market analysis.
Overall, Auto Trend Projection offers a convenient and automated approach to projecting short-term trends, empowering traders with valuable insights into the potential price direction.
Strongest TrendlineUnleashing the Power of Trendlines with the "Strongest Trendline" Indicator.
Trendlines are an invaluable tool in technical analysis, providing traders with insights into price movements and market trends. The "Strongest Trendline" indicator offers a powerful approach to identifying robust trendlines based on various parameters and technical analysis metrics.
When using the "Strongest Trendline" indicator, it is recommended to utilize a logarithmic scale . This scale accurately represents percentage changes in price, allowing for a more comprehensive visualization of trends. Logarithmic scales highlight the proportional relationship between prices, ensuring that both large and small price movements are given due consideration.
One of the notable advantages of logarithmic scales is their ability to balance price movements on a chart. This prevents larger price changes from dominating the visual representation, providing a more balanced perspective on the overall trend. Logarithmic scales are particularly useful when analyzing assets with significant price fluctuations.
In some cases, traders may need to scroll back on the chart to view the trendlines generated by the "Strongest Trendline" indicator. By scrolling back, traders ensure they have a sufficient historical context to accurately assess the strength and reliability of the trendline. This comprehensive analysis allows for the identification of trendline patterns and correlations between historical price movements and current market conditions.
The "Strongest Trendline" indicator calculates trendlines based on historical data, requiring an adequate number of data points to identify the strongest trend. By scrolling back and considering historical patterns, traders can make more informed trading decisions and identify potential entry or exit points.
When using the "Strongest Trendline" indicator, a higher Pearson's R value signifies a stronger trendline. The closer the Pearson's R value is to 1, the more reliable and robust the trendline is considered to be.
In conclusion, the "Strongest Trendline" indicator offers traders a robust method for identifying trendlines with significant predictive power. By utilizing a logarithmic scale and considering historical data, traders can unleash the full potential of this indicator and gain valuable insights into price trends. Trendlines, when used in conjunction with other technical analysis tools, can help traders make more informed decisions in the dynamic world of financial markets.
MultiMovesCombines 3 different moving averages together with the linear regression. The moving averages are the HMA, EMA, and SMA. The script makes use of two different lengths to allow the end user to utilize common crossovers in order to determine entry into a trade. The edge of each "cloud" is where each of the moving averages actually are. The bar color is the average of the shorter length combined moving averages.
-The Hull Moving Average (HMA), developed by Alan Hull, is an extremely fast and smooth moving average. In fact, the HMA almost eliminates lag altogether and manages to improve smoothing at the same time. A longer period HMA may be used to identify trend.
-The exponential moving average (EMA) is a technical chart indicator that tracks the price of an investment (like a stock or commodity) over time. The EMA is a type of weighted moving average (WMA) that gives more weighting or importance to recent price data.
-A simple moving average (SMA) is an arithmetic moving average calculated by adding recent prices and then dividing that figure by the number of time periods in the calculation average.
-The Linear Regression Indicator plots the ending value of a Linear Regression Line for a specified number of bars; showing, statistically, where the price is expected to be. Instead of plotting an average of past price action, it is plotting where a Linear Regression Line would expect the price to be, making the Linear Regression Indicator more responsive than a moving average.
The lighter colors = default 50 MA
The darker colors = default 200 MA