TrendMaster ProTrendMaster Pro: A Comprehensive Trend Analysis Tool for Long-Term Investors
TrendMaster Pro is an advanced technical indicator designed to provide long-term investors with a robust and comprehensive analysis of market trends. This sophisticated tool operates exclusively on daily timeframes, making it ideal for those focused on long-term investment strategies. By combining multiple analytical approaches, TrendMaster Pro offers investors a powerful means to assess trend quality and make informed decisions.
Automatic Trend Detection
At the heart of TrendMaster Pro lies its ability to automatically identify the most statistically significant trend. The indicator analyzes various timeframes ranging from 1000 to 5000 days, selecting the one that exhibits the highest correlation. This feature ensures that investors are always working with the most relevant trend data, eliminating the subjectivity often associated with manual trend identification.
The trend detection algorithm employs a regression analysis approach, evaluating approximately 80,000 different trend alternatives each day. Each potential trend is assigned a score based on criteria such as trend density, deviation from regression, and the number of price points near the trend's floor and ceiling. The trend with the highest score is then selected and displayed on the chart.
Comprehensive Scoring System
TrendMaster Pro employs a multi-faceted scoring system that evaluates four key aspects of a trend, providing a holistic view of its quality and potential. Each aspect is scored on a scale of 0 to 10, with the overall trend quality score being a weighted average of these individual scores.
1. Length Score
The Length Score measures the duration of the detected trend. Longer trends receive higher scores, reflecting increased reliability and significance. This score is calculated by normalizing the auto-selected period (which ranges from 1000 to 5000 days) to a scale of 5 to 10.
For example, if the auto-selected period is 3000 days, it would receive a score of around 7.5. This emphasizes the importance of long-term trends in investment decision-making, as they tend to be more stable and indicative of underlying market forces.
2. Strength Score
The Strength Score utilizes Pearson's Correlation Coefficient to assess trend strength. This statistical measure gauges the linear relationship between price and trend projection. A value closer to 1 indicates a strong positive correlation, reinforcing confidence in the trend direction based on historical price movements.
The indicator translates the Pearson's Correlation Coefficient into a score from 0 to 10. For instance, a correlation coefficient of 0.95 might translate to a Strength Score of 8, indicating a strong and reliable trend.
3. Performance Score
The Performance Score compares the asset's Compound Annual Growth Rate (CAGR) to a chosen benchmark, typically a major index like the S&P 500. This score provides insight into how well the asset is performing relative to the broader market.
The CAGR is calculated using the formula: CAGR = (Ending Value / Beginning Value)^(1/n) - 1, where n is the number of years. The Performance Score is then determined by comparing this CAGR to the benchmark's CAGR over the same period. A higher score indicates outperformance relative to the benchmark.
4. Level Score
The Level Score evaluates the current price position within the trend channel. Lower prices within the channel receive higher scores, suggesting potential value or buying opportunities. This score helps identify possible entry points based on historical trend behavior.
For example, if the current price is near the lower boundary of the trend channel, it might receive a Level Score of 9, indicating a potentially attractive entry point.
Visual Representation
TrendMaster Pro provides a clear visual representation of the detected trend by displaying a regression channel on the chart. This channel consists of three lines: a middle line representing the main trend, and upper and lower lines representing standard deviations from the main trend.
The channel offers a quick visual reference for support and resistance levels, helping investors identify potential entry and exit points. The color and style of these lines can be customized to suit individual preferences.
Detailed Information Table
A comprehensive table presents all scores and relevant data, allowing for quick and easy interpretation of the trend analysis. This table includes:
The auto-selected trend length
The Pearson's Correlation Coefficient
The asset's CAGR and the benchmark's CAGR
Individual scores for Length, Strength, Performance, and Level
The overall Trend Quality Score
This table provides investors with a clear, at-a-glance summary of the trend's key characteristics and quality.
Practical Application
To use TrendMaster Pro effectively, investors should consider the following:
Focus on the overall Trend Quality Score as a primary indicator of trend strength and reliability.
Use the Length Score to gauge the trend's longevity and potential stability.
Pay attention to the Strength Score to assess how well the price action aligns with the identified trend.
Utilize the Performance Score to compare the asset's performance against the broader market.
Consider the Level Score when timing entries, looking for opportunities when prices are relatively low within the trend channel.
Use the visual trend channel as a guide for potential support and resistance levels.
Limitations and Considerations
While TrendMaster Pro offers powerful insights, it's important to remember that no indicator can predict future market movements with certainty. The tool should be used in conjunction with fundamental analysis and other market information.
Additionally, as the indicator is designed for daily charts and long-term analysis, it may not be suitable for short-term trading strategies. Users should also be aware that past performance does not guarantee future results, even with strong trend indications.
Conclusion
TrendMaster Pro represents a significant advancement in trend analysis for long-term investors. By combining automatic trend detection, comprehensive scoring, and benchmark comparison, it offers a powerful tool for those seeking to make informed, data-driven investment decisions. Its ability to objectively assess trend quality across multiple dimensions provides investors with a valuable edge in navigating complex market conditions.
For investors looking to deepen their understanding of market trends and enhance their long-term investment strategies, TrendMaster Pro offers a sophisticated yet accessible solution. As with any investment tool, users are encouraged to thoroughly familiarize themselves with its features and interpret its outputs in the context of their overall investment approach.
Regression-trend-channel
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.
SUPER GCOV5 MAPSCALP > MAPPING & SCALPING SUPER GCOV5 MAPSCALP indicator is built specifically for mapping/prediction measurement and fast trading i.e. scalping/intraday in the commodity market or cryptos market. It uses an indicator instrument consisting of ATR TRAILING STOP (ATR), EXPONENTIAL MOVING AVERAGE, PIVOT POINT, FIBONACCI KEY LEVEL, and LINEAR REGRESSION CHANNEL(LRC).
Rebuild of Instrument & Parameter
This indicator is also an upgraded instrument that is sourced from the previous indicator-FUTURES SCALPV2.This R&D of course makes trading activities more effective, and dynamic to increase the confidence of traders in current trading activities. The indicator has been upgraded in terms of parameters as well as additional instruments. Among them are;
1. ATR Trailing Stop
2. ATR BUY/SELL signal
3. Exponential Moving Average(EMA) – fastMA/slowMA Length
5. Breakout/breakdown signal
6. Pivot low/high level
7. Fibonacci extends & retracement
8. Linear Regression Channel(LRC)
9. Alert condition ( a dozen alerts )
> The best timeframe for entry is 3 minutes for FCPO and 15 minutes for other futures & cryptos.
> The best timeframe mapping/prediction is 1 hour & 4 hours.
>The candle/bars have been colored to make it easier for traders to see the price trends whether in bullish or bearish conditions.
Easier SOP of ENTRIES/POSITIONING:
1. entry by signal BUY/SELL after signal bar ( 2nd bar) for confirmation.
2. The best entries BUY at support(pivot low-Blue line) after price rebound then signal appears. The best buy also when the price is at lower
low pivot + fibo support level + lower trendline(LRC) + and the price went rebound.
3. The best entries SELL at resistance(pivot high-red line) after price pullback then signal appears.
The best buy also when the price is at a higher high pivot + fibo resistance level + upper trendline LRC + and the price went pullback.
4. Profit-taking areas are usually measured by support and resistance levels. Please refer to the bold line( support & resistance), fibo key level,
and trendline.
*To avoid false signals/wrong positions, you can use the EMA line as a guide and follow the trends, which are the buying weight when the price is above the 20/50 ema, and the selling weight when the price is below the 20/50 ema. EMA can be reset on the input setting.
STEPS of MAPPING/PROJECTION:
1. Use a bigger timeframe such as 4 hours or 1 hour
2. Use LRC to identify buy/sell weights when the price makes a zig-zag patent
3. Use monthly and weekly fibo levels to know support and resistance. This fibo is very important to see if the price will make an extension or
retracement based on the regression channel earlier. So here we can evaluate which area to buy/sell/take-profit/exit and the reversal of a
market price.
You can also create an ALERT CONDITION to help you get a reminder of signals and price trend changes
The original instrument has been retained but changed in terms of display & facelift features.
Hopefully, the new one will assist you in making analysis and strategy of trading activities successfully.
THIS IS NOT A BUY/SELL CALL, ONLY STUDY IDEAS AND ANALYSIS BASED ON MEASUREMENT TOOLS FOR EDUCATION AND GUIDANCE PURPOSES.PLEASE TAKE AT YOUR OWN RISK.
Regression Channel Trend DetectionThis is a regression channel that uses ichimoku to determine trend. The sensitivity is customizable. The centerline will change color according to the trend detected by ichimoku, and each line can act as support/resistance. The bands of the channel also change colors according to how far price is getting away from them. If you notice in this example, the lower band is turning orange when the price is getting too far away from it, suggesting that it may have risen too fast and too soon. This is still in testing so feel free to comment with any suggestions or fixes.
TF Segmented Polynomial Regression [LuxAlgo]This indicator displays polynomial regression channels fitted using data within a user selected time interval.
The model is fitted using the same method described in our previous script:
Settings
Degree: Degree of the fitted polynomial
Width: Multiplicative factor of the model RMSE. Controls the width of the polynomial regression's channels
Timeframe: Fits the polynomial regression using data within the selected timeframe interval
Show fit for new bars: If selected, will fit the regression model for newly generated bars, else the previous fitted value is displayed.
Src: Input source
Usage
Segmented (or piecewise) models yield multiple fits by first partitioning the data into multiple intervals from specific partitioning conditions. In this script this partitioning condition is for a user selected timeframe to change.
Segmented models can be particularly pertinent for market prices, which often describes a series of local trends.
Segmented polynomial regressions can describe the nature of underlying trends in the price from their fit, such as if an underlying trend is more linear (trending) or constant (ranging), and if a trend is monotonic.
The above chart shows a monthly partitioning on SPX 15m, using a polynomial regression of degree 3. Channel extremities allows highlighting local tops/bottoms.
For real time applications users can choose to fit a current model to incoming price data using the Show fit for new bars settings.
Details
The script does not make use of line.new to display the segmented linear regressions, which allows showing a higher number of historical fits. Each channel extremity as well as the model fit is displayed from the plot function, as such user can more easily set alerts on them.
It is important to note that achieving this requires accessing future price data, as such this script is subject to lookahead bias, historical results differ from the results one could have obtained in real-time.
Infiten's Regressive Trend Channel An experiment using Pinescript's candle plotting feature. This indicator performs a linear regression on the lows, highs, and moving average, and plots them all in the form of a candlestick. If the close is below the prediction, the candlestick is red, if the close is above the regression, the candlestick is green. Effective and aesthetic way to analyze trends.
Linear Regression Channel - Auto Volume BasedBased on oryginal TV indicator BUT with a little twist. ;)
I really like the regression channel - but the problem is that the length needs to be always manually adjusted.
In this script I try to solve this issue.
This is modified version on TV indicator - Linear Regression Channel.
The main difference is that now you don't get static length - it is automatically adjuested to the recent price action (determined by highest volume in last 300 bars).
Linear Regression Relative Strength[image/x/iZvwDWEY/
Relative Strength indicator comparing the current symbol to SPY (or any other benchmark). It may help to pick the right assets to complement the portfolio build around core ETFs such as SPY.
The general idea is to show if the current symbol outperforms or underperforms the benchmark (SPY by default) when bought some certain time ago. Relative performance is displayed as percent and is calculated for three different time ranges - short (1 mo by default), mid (1 quarter), and long (half a year). To smooth the volatility, the script uses linear regression to estimate the trend and takes the start and the end points of the linear regression line to compute the relative strength.
It is important to remember that the script shows the gain relative to SPY (or other selected benchmark), not the asset's gain. Therefore, it may indicate that the asset is profitable, but it still may lose value if SPY is in downtrend.
Therefore, it is crucial to check other indicators before making a decision. In the example above, standard linear regression for one quarter is used to indicate the direction of the trend.
NEXT Regressive VWAPOverview:
This version of the Volume-Weighted Average Price (VWAP) indicator features an extended algorithm, which, in addition to volume and price, also incorporates regression analysis. The result is a more responsive, often leading VWAP slope with a degree of statistical predictability built in. Just like with the original VWAP, NEXT Regressive VWAP offers two optional Standard Deviation bands that parallel it. These can be set to any deviation level, with the default being 1 and -1, indicating one standard deviation above and one below Regressive VWAP, respectively.
Below is a screenshot comparing NEXT Regressive VWAP (green) to the original VWAP (blue) on CME_MINI:ES1! M3 chart.
Application and Strategy Ideas:
Price above NEXT Regressive VWAP is interpreted to have a bullish bias, and below, bearish. You can use TradingView's native Set Alert functionality to be notified, in real-time, when price crosses Regressive VWAP, and/or any of its standard deviation bands. Another popular "probability play" strategy is to scalp price when it crosses under the upper band (short) and crosses over the lower band (long). The screenshot below visualizes such a strategy on NASDAQ:QQQ M1 chart:
Input Parameters:
There are 3 groups of input.
Regression Settings
Length - controls the length of time (in bars) for regression analysis with higher values yielding smoother, more responsive values.
Regression Weighting - controls the degree of regression analysis incorporated into VWAP, with 5 being average, 0-4 less, 6-10 more. The higher the value, the more responsive the Regressive VWAP curve.
VWAP Settings
Anchor Period - controls the origin of VWAP calculations, start of session being the default.
Source - data used for calculating the VWAP, typically HLC/3, but can be used with other price formats and data sources as well.
Offset - shifting of the VWAP line forward (+) or backward (-).
Standard Deviation Bands Settings
Calculate Bands - checking this will add 2 bands, each equidistant (by the amount of Multiplier) from the NEXT Regressive VWAP line.
Bands Multiplier - standard deviation multiplier, with 1 being the default
Signals and Alerts:
Here is how to set price (close) crossing NEXT Regressive VWAP alerts: open a chart, attach NEXT Regressive VWAP, and right-click on chart -> Add Alert. Condition: Symbol e.g. ES (close) >> Crossing >> Regressive VWAP >> VWAP >> Once Per Bar Close.
Bitcoin Logarithmic Regression RainbowI know there are a lot of BTC rainbows out there, I just wanted to publish my version with my fittings to the BTC price.
The grey channel at the bottom encloses the March 2020 Corona dump.
For best experience USE WEEKLY TIMEFRAME .
Mayfair Advanced Regressions 1.0This indicator maps two regressions.
The outer regression (green straight lines in the chart) tracks the main trend. It save you from working out your own trend channels, BUT it does move with the price, so it is different from a static channel. You can use it as a template for drawing static channels though.
The inner regression (the curved lines) is a parabolic regression. It shows the shorter term trend within the outer trend. This helps traders to judge when it is right or wrong to take a position on the edge of the main regression, based on whether the inner regression is indicating an acceleration out of the channel, or is shaping to go with the main trend.
We find it works best if there is a clear trend. If the market is not trending, then there isn't much point using a trend analysis tool like this.
Like all indicators, it is not perfect, and you should never rely on one indicator in any situation.
Moving Regression Prediction BandsIntroducing the Moving Regression Prediction Bands indicator.
Here I aimed to combine the principles of traditional band indicators (such as Bollinger Bands), regression channel and outlier detection methods. Its upper and lower bands define an interval in which the current price was expected to fall with a prescribed probability, as predicted by the previous-step result of the local polynomial regression (for the original Moving Regression script, see link below).
Algorithm
1. At every time step, the script performs local polynomial regression of the sample data within the lookback window specified by the Length input parameter.
2. The fitted polynomial is used to construct the Moving Regression time series as well as to extrapolate data, that is, to predict the next data point ( MRPrediction ).
3. The accuracy of local interpolation is estimated by means of the root-mean-square error ( RMSE ), that is, the deviation between the fitted polynomial and the observed values.
4. The MRPrediction and RMSE values calculated for the previous bar are then used to build the upper and lower bands , which I define as follows:
Upper Band = MRPrediction_prev + Multiplier *( RMSE_prev )
Lower Band = MRPrediction_prev - Multiplier *( RMSE_prev )
Here the Multiplier is a user-defined parameter that should be interpreted as a quantile in the standard normal distribution (the default value of 2.0 roughly corresponds to the 95% prediction interval).
To visualize the central line , the script offers the following options:
Previous-Period MR Prediction: MRPrediction_prev time series from the above equation.
MR: Conventional Moving Regression time series.
Ribbon: “Previous-Period MR Prediction” and “MR” curves plotted together and colored according to their relative value (green if MR > Previous MR Prediction; red otherwise).
Usage
My original idea was to use the band breakouts as potential trading signals. For example, the price crossing above the upper band is a bullish signal , being a potential sign that price is gaining momentum and is out of a previously predicted trend. The exit signal could be the crossing under the lower band or under the central line.
However, be aware that it is an experimental indicator, so you might fin some better strategies.
Feel free to play around!
GAURs Polynomial Regression ChannelsThanks to The Sweet Lord , here is the Gaur's Polynomial Regression Channel.
Its a Polynomial Regression Channel but applied a little differently. Wont go into technical details much. Overview of options is as follows-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Channel Options
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1. Degree of Polynomial: 1/2/3
Default = 3
Defines the degree of polynomials - 1,2,3. Note here, degree 1 will not be a straight line since its applied differently.
Try different degrees for different fits and market conditions.
2. Channel Length:
Default 30 (candles)
You can go beyond 100 or 200 candle lengths but smaller is the usual preference of Poly-Reg-channel traders. It all depends on market conditions and your style of trading. Do your research. I am usually comfortable with a range of 20-50 (in crypto markets).
3. Basis of Channel height/boundries: ATR/Manual
Default: ATR
ATR provides a dynamically adjusted entry/exit bounds of the channels. As ATR changes, the channel bounds also changes its height. It can also be fixed manually. Manual heights wont change automatically.
4. Basis of Y-Value: open/close/ sma / ema / wma /hilow
Default: close
Y- value is the y value of the (x,y) coordinates used while calculating the regression coefficients. Dont worry about it, its nothing serious.
5. Apply channel smoothning using sma?: Yes/No
Default: Yes
Without smoothning, the channel does not "look" good.
6. Shaded Area Height Percentage:
Its the extra margin for the channel. Its in percentage of the total height (defined 3 above) of channels. The shaded area provides an extra allowance for your entries or exits beyond the ATR or manual heights.
7. Plot RSI?: Yes/No
Default: Yes
Plots RSI (orange line in between the channel - its different from the dotted center line) considering the downbound of channels as 0 (oversold) and upbound of channels as 100 (overbought)
8. Plot 200 sma?: Yes/No
Default: Yes
It plots a 200 period fast (green) and 225 period slow (red) sma . I usually use two MAs. Its visually very easy to understand.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Sample Strategy
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
You can develop your own strategy with the channels. But following is just one of the ways you can trade.
Best Application: Ranging markets. But can be happily used in volatile conditions, with a little experience.
1. SMA: -- (this condition is optional really)
If green (200) is above red (225) go only long. If red is above green go only short. Defines long term trend of the market.
2. Channel slope: -- (this stuff needs practice/experience)
Depending on the channel slope, like if its tending to go up or down, you can choose to take only short or long trades. It defines short term momentum of the market.
3. ATR based heights:
Since its ATR based, the channel height are our natural entry and exit points.
Long:
When price touches lower shaded area, consider possible long entry. Exit on price entering the upper shaded area.
Short:
Enter on upper bound shaded area, exit on lower.
4. RSI:
For additional conformations. Again note, the RSI considers the lower bound of channel as 0 and upper as 100. But since, the channel moves up and down, the RSI will also move not only as RSI but also with the channel. Meaning, say if the RSI is valued at 50, then it will be near the center of the channel but since the center changes as time and price changes, the RSI valued at 50 at different times will not be at the same horizontal level respect to the graph, although it will be at the same level (center) respect to the channel.
5. PRC Channel Percentage label:
This label is at the lower side a bit ahead of the current candle. Provides you info on what is the channel percentage. This is especially helpful in crypto markets to gauge your possible percentage profit where profits can be much higher than forex or other instruments. It can also helps you select a suitable market/instrument if the channels are based on ATR.
6. Extra indicators:
I usually use stochastic along with this setup for extra conformations.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Donate
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use freely and donate generously if you find value. Your help will really help.
I had earlier provided BTC addresses for donations but it seems to violate TV House rules.
Hope they make TV coins redeemable in future.
- Pranav Joshi
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Extra Info
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// © cpranavjoshi
// special thanks to the "Trading View" people for providing this great platform for free
// ------------------------
// MATH
// ------------------------
// special thanks to an article on the web that provided layman friendly explanation of the maths
// unfortunately i wont be able to provide the link to that article owing to TV restrictions, though i sincerely would have liked to credit the author.
// Google search this phrase, and you should be able to get it in one of the first results - "polynomialregression Mathematics of Polynomial Regression"
// my regression math calculation is a further resolution upon the generalized matrix formula given in the that article.
// the generalized matrix looks scary but in fact its much simpler than one may assume
// the summation sign things are just float numbers that can be easily found out
// so we get a matrix with number of equations equal to the number of unknowns.
// e.g. if its a 3rd degree poly, it has 4 unknowns (c0,c1,c2,c3) with 4 equations as in the generalized matrix
// it can be resolved by simple algebra
// Note: the results have been verified with excel using same input data points.
// pine was difficult for me so i coded it in python first to verify
// ------------------------
// WHY
// ------------------------
// this script was coded because Pranav badly needed Polynomial channels (had used them in mt4 earlier)
// and at the time of this coding, i could not find any readily available script in the trading view public library ( tnx public)
// the complex math was probably the hurdle
// i m not good in maths, but by the Will of the Lord, i could resolve the issue with simple algebra and logic
// ------------------------
// PINE
// ------------------------
// i am just an average (even poor probably) programmer and pine script is not my language
// this is a humble attempt to write my first pine with whatever i could do quickly
// experts - feel free to develop if needed. have used some workarounds in drawings/plottings. rectify them if possible
//
//
// - Pranav Joshi
Linear Regression ChannelLinear Regression Channel designed for easy analysis with 18 lines instead of the standard three.
BTC Moon MathBTC long term regression analysis inspired by the work of many others: DonovanWall, hcburger1, intheloop, davthewave.
For use on BTC only, for longer term analysis use ticker BNC:BLX for BraveNewCoin's Bitcoin index going back to 2010. Looks best on weekly timeframes. Intended for use on log charts.
Regression Channel [DW]This is an experimental study which calculates a linear regression channel over a specified period or interval using custom moving average types for its calculations.
Linear regression is a linear approach to modeling the relationship between a dependent variable and one or more independent variables.
In linear regression, the relationships are modeled using linear predictor functions whose unknown model parameters are estimated from the data.
The regression channel in this study is modeled using the least squares approach with four base average types to choose from:
-> Arnaud Legoux Moving Average (ALMA)
-> Exponential Moving Average (EMA)
-> Simple Moving Average (SMA)
-> Volume Weighted Moving Average (VWMA)
When using VWMA, if no volume is present, the calculation will automatically switch to tick volume, making it compatible with any cryptocurrency, stock, currency pair, or index you want to analyze.
There are two window types for calculation in this script as well:
-> Continuous, which generates a regression model over a fixed number of bars continuously.
-> Interval, which generates a regression model that only moves its starting point when a new interval starts. The number of bars for calculation cumulatively increases until the end of the interval.
The channel is generated by calculating standard deviation multiplied by the channel width coefficient, adding it to and subtracting it from the regression line, then dividing it into quartiles.
To observe the path of the regression, I've included a tracer line, which follows the current point of the regression line. This is also referred to as a Least Squares Moving Average (LSMA).
For added predictive capability, there is an option to extend the channel lines into the future.
A custom bar color scheme based on channel direction and price proximity to the current regression value is included.
I don't necessarily recommend using this tool as a standalone, but rather as a supplement to your analysis systems.
Regression analysis is far from an exact science. However, with the right combination of tools and strategies in place, it can greatly enhance your analysis and trading.
LinearRegressionChannelBreakoutMy first idea about the linear regression channel... It is free and available for everybody.