[RS]Shotgun ForecastsExperimental:
its a play at linear forecasting.
use replay feature to see it in action:
streamable.com
Linear
Price-Line Channel - A Friendly Support And Resistance IndicatorIntroduction
Lines are the most widely used figures in technical analysis, this is due to the linear trends that some securities posses (daily log SP500 for example), support and resistances are also responsible for the uses of lines, basically linear support and resistances are made with the assumption that the line connecting two local maximas or minimas will help the user detect a new local maxima or minima when the price will cross the line.
Technical indicators attempting to output lines have always been a concern in technical analysis, the mostly know certainly being the linear regression, however any linear models would fit in this category. In general those indicators always reevaluate their outputs values (repainting), others non repainting indicators returning lines are sometimes to impractical to set-up. This is what has encouraged me to make a simpler indicator based on the framework used in the recursive bands indicator that i published.
The proposed indicator aim to be extremely flexible and easy to use while returning linear support and resistances, an option that allow readjustment is also introduced, thus allowing for a "smarter" indicator.
The Indicator
The indicator return two extremities, the upper one aim to detect resistance points while the lower one aim to detect support points. The length setting control the steepness of the line, with higher values of length involving a lower slope, this make the indicator less reactive and interact with the price less often.
The name "price-line" comes from the fact that the channel is dependent on its own interaction with the price, therefore a breakout methodology can also be used, where price is up-trending when crossing with the upper extremity and down trending when crossing with the lower one.
Readjusted Option
The line steepness can be readjusted based on the market volatility, it make more sense for the line to be more steep when the market is more volatile, thus making it converge faster toward the price, this of course is done at the cost of some linearity. This is achieved by checking the "readjustment" option. The effects can be shown on BTCUSD, below the indicator without the readjusted option :
when the "readjustment" option is checked we have the following results :
The volatile down movement on BTCUSd make the upper extremity converge faster toward the price, this option can be great for volatile markets.
Conclusion
The recursive bands indicator prove to be an excellent framework that allow for the creation of lots of indicators, the proposed indicator is extremely efficient and provide an easy solution for returning linear support and resistances without much drawbacks, the readjusted option allow the indicator to adapt to the market volatility at the cost of linearity.
The performance of the indicator is relative to the motion of the price, however the indicator show signs of returning accurate support and resistances points. I hope the indicator find its use in the community.
Thanks for reading !
Note
Respect the house rules, always request permission before publishing open source code. This is an original work, requesting permission is the least you can do.
Forecasting - Drift MethodIntroduction
Nothing fancy in terms of code, take this post as an educational post where i provide information rather than an useful tool.
Time-Series Forecasting And The Drift Method
In time-series analysis one can use many many forecasting methods, some share similarities but they can all by classified in groups and sub-groups, the drift method is a forecasting method that unlike averages/naive methods does not have a constant (flat) forecast, instead the drift method can increase or decrease over time, this is why its a great method when it comes to forecasting linear trends.
Basically a drift forecast is like a linear extrapolation, first you take the first and last point of your data and draw a line between those points, extend this line into the future and you have a forecast, thats pretty much it.
One of the advantage of this method is first its simplicity, everyone could do it by hand without any mathematical calculations, then its ability to be non-conservative, conservative methods involve methods that fit the data very well such as linear/non-linear regression that best fit a curve to the data using the method of least-squares, those methods take into consideration all the data points, however the drift method only care about the first and last point.
Understanding Bias And Variance
In order to follow with the ability of methods to be non-conservative i want to introduce the concept of bias and variance, which are essentials in time-series analysis and machine learning.
First lets talk about training a model, when forecasting a time-series we can divide our data set in two, the first part being the training set and the second one the testing set. In the training set we fit a model to the training data, for example :
We use 200 data points, we split this set in two sets, the first one is for training which is in blue, and the other one for testing which is in green.
Basically the Bias is related to how well a forecasting model fit the training set, while the variance is related to how well the model fit the testing set. In our case we can see that the drift line does not fit the training set very well, it is then said to have high bias. If we check the testing set :
We can see that it does not fit the testing set very well, so the model is said to have high variance. It can be better to talk of bias and variance when using regression, but i think you get it. This is an important concept in machine learning, you'll often see the term "overfitting" which relate to a model fitting the training set really well, those models have a low to no bias, however when it comes to testing they don't fit well at all, they have high variance.
Conclusion On The Drift Method
The drift method is good at forecasting linear trends, and thats all...you see, when forecasting financial data you need models that are able to capture the complexity of the price structure as well as being robust to noise and outliers, the drift method isn't able to capture such complexity, its not a super smart method, same goes for linear regression. This is why more peoples are switching to more advanced models such a neural networks that can sometimes capture such complexity and return decent results.
So this method might not be the best but if you like lines then here you go.
Auto Trend Channel [Anan]Hello Friends..
This is Auto Trend Channel using linear regression ,,
So helpful and smart !
Play with the options to adjust the precision.
*Note that the selected time frame in options must be > your current time frame (logic) to draw lines.
Forecasting - Holt’s Linear Trend ForecastingHolt's Forecasting method
Holt (1957) extended simple exponential smoothing to allow the forecasting of data with a trend. This method involves a forecast equation and two smoothing equations (one for the level and one for the trend):
Forecast equation: ŷ = l + h * b
Level equation: l = alpha * y + (1 - alpha) * (l + b)
Trend equation: b = beta * (l - l) + (1 - beta) * b
where:
l (or l) denotes an estimate of the level of the series at time t,
b (or b) denotes an estimate of the trend (slope) of the series at time t,
alpha is the smoothing parameter for the level, 0 ≤ alpha ≤ 1, and
beta is the smoothing parameter for the trend, 0 ≤ beta ≤ 1.
As with simple exponential smoothing, the level equation here shows that l is a weighted average of observation y and the one-step-ahead training forecast for time t, here given by l+b. The trend equation shows that b is a weighted average of the estimated trend at time t based on l-l and b, the previous estimate of the trend.
The forecast function is not flat but trending. The h-step-ahead forecast is equal to the last estimated level plus h times the last estimated trend value. Hence the forecasts are a linear function of h.
Linear Regression Trend ChannelThis is my first public release of indicator code and my PSv4.0 version of "Linear Regression Channel", as it is more commonly known. It replicates TV's built-in "Linear Regression" without the distraction of heavy red/blue fill bleeding into other indicators. We can't fill() line.new() at this time in Pine Script anyways. I entitled it Linear Regression Trend Channel, simply because it seems more accurate as a proper description. I nicely packaged this to the size of an ordinary napkin within 20 lines of compact code, simplifying the math to the most efficient script I could devise that fits in your pocket. This is commonly what my dense intricate code looks like behind the veil, and if you are wondering why there is no notes, that's because the notation is in the variable naming. I excluded Pearson correlation because it doesn't seem very useful to me, and it would comprise of additional lines of code I would rather avoid in this public release. Pearson correlation is included in my invite-only advanced version of "Enhanced Linear Regression Trend Channel", where I have taken Linear Regression Channeling to another level of fully featured novel attainability using this original source code.
Features List Includes:
"Period" adjustment
"Deviation(s)" adjustment
"Extend Method" option to extend or not extend the upper, medial, and lower channeling
Showcased in the chart below is my free to use "Enhanced Schaff Trend Cycle Indicator", having a common appeal to TV users frequently. If you do have any questions or comments regarding this indicator, I will consider your inquiries, thoughts, and ideas presented below in the comments section, when time provides it. As always, "Like" it if you simply just like it with a proper thumbs up, and also return to my scripts list occasionally for additional postings. Have a profitable future everyone!
Time Series ForecastIntroduction
Forecasting is a blurry science that deal with lot of uncertainty. Most of the time forecasting is made with the assumption that past values can be used to forecast a time series, the accuracy of the forecast depend on the type of time series, the pre-processing applied to it, the forecast model and the parameters of the model.
In tradingview we don't have much forecasting models appart from the linear regression which is definitely not adapted to forecast financial markets, instead we mainly use it as support/resistance indicator. So i wanted to try making a forecasting tool based on the lsma that might provide something at least interesting, i hope you find an use to it.
The Method
Remember that the regression model and the lsma are closely related, both share the same equation ax + b but the lsma will use running parameters while a and b are constants in a linear regression, the last point of the lsma of period p is the last point of the linear regression that fit a line to the price at time p to 1, try to add a linear regression with count = 100 and an lsma of length = 100 and you will see, this is why the lsma is also called "end point moving average".
The forecast of the linear regression is the linear extrapolation of the fitted line, however the proposed indicator forecast is the linear extrapolation between the value of the lsma at time length and the last value of the lsma when short term extrapolation is false, when short term extrapolation is checked the forecast is the linear extrapolation between the lsma value prior to the last point and the last lsma value.
long term extrapolation, length = 1000
short term extrapolation, length = 1000
How To Use
Intervals are create from the running mean absolute error between the price and the lsma. Those intervals can be interpreted as possible support and resistance levels when using long term extrapolation, make sure that the intervals have been priorly tested, this mean the intervals are more significants.
The short term extrapolation is made with the assumption that the price will follow the last two lsma points direction, the forecast tend to become inaccurate during a trend change or when noise affect heavily the lsma.
You can test both method accuracy with the replay mode.
Comparison With The Linear Regression
Both methods share similitudes, but they have different results, lets compare them.
In blue the indicator and in red a linear regression of both period 200, the linear regression is always extremely conservative since she fit a line using the least squares method, at the contrary the indicator is less conservative which can be an advantage as well as a problem.
Conclusion
Linear models are good when what we want to forecast is approximately linear, thats not the case with market price and this is why other methods are used. But the use of the lsma to provide a forecast is still an interesting method that might require further studies.
Thanks for reading !
Linear Trailing StopBased on my latest script "Linear Channels"
This is a trailing stop version of the linear channels. Thanks to capissimo for helping me fix several issues with the linear extrapolation part.
In order to know how the indicator work i recommend reading the post on the Linear Channels indicator here
Hope you like it and feel free to leave your suggestions :)
Linear ChannelsIntroduction
I already made an indicator (simple line) that tried to make lines on price such that the results would not repaint and give a good fit to the price, today i publish a channels indicator based on the simple line indicator. The indicator aim to show possible support and resistance levels when the central line posses a low sum of squares with the price, a linear extrapolation was also provided in order to show possible future price positions respective to the channels.
The Indicator
The emphasis parameter of the simple line indicator has been removed, instead we keep length and mult as numerical input parameters. In general length control how persistent the lines are, larger values will create longer lines on average, mult help make the line fit to the price better but might as well affect how spread the channels are as well as the lines average length. When mult > length the lines will fit better the price while when length >= mult the fit might not be the best.
The point parameter allow you to fix the indicator when using it on high market price values or when the indicator exhibit a weird behaviour.
point = false on btcusd
point = true
If the lines still does not fit well enough try to lower length.
I know this might result inconvenient in so many ways but i'am working on simplifying things. Therefore some larger price values might use lower length and use mult instead. For market not using the point parameters a settings of : length > 1 and mult = length*2 might provide a good to go setup.
The channel spreading parameter allow to make spread the channels by a certain factor.
Issues
I'am still not good with line extensions, if it bother you deactivate the extrapolation parameter. Sorry for the inconvenience.
Conclusion
It is possible to make non repainting linear indicators, and i'am working on some of them. While some might argue that price is not linear thus not requiring the use of linear indicators it can still be interesting to use those if they, unlike the linear regression, don't repaints and provide a way to change their directions according to the price trend.
Thanks for reading !
Linear Moving Average by Atilla YurtsevenLinear moving average is one of the best indicators i have written. LMA works like trend lines. Whatever lookback period you chose, it doesn't go very far away from the price.
Disclaimer: This is not financial advice
Remember to follow me if you like to get notified when i publish new indicators or analysis
Trade safe
Atilla
Trading System(Dark)Combo of many useful indicators, contains
1)Regular and Hidden Divergence Buy and Sell signals by scarf
2)Time and Money channels by Lazybear
3)Fibonacci Bollinger Bands by Rashad
4)Linear Regression Curve by ucsgears
Thanks for all the creators for the source codes!
linear regression channel (lirshah)linear regression channel is an indicator which has been written according to linear regression and exponential moving average (ema).
the indicator nicely shows major trend and key levels and has a good performance on almost all pairs and time frames.
Trend-based Lindratic RegressionThis is an effective trend-following script that uses a finite volume element, linear regression, quadratic regression and multiple EMAs to define appropriate times to enter and exit the market. It can be applied to any asset that has volume data available for it.
As it follows the trend it's a very low-risk strategy, but it's not made to catch and ride reversals. It would rather close a long at the top and close a short at the bottom, although this means you can expect not to be stopped out on any trade you take.
Works on any timeframe, although I did create this with the intention of scalping, so shorter timeframes are recommended.
Combined with a volatility filter, this would be a very effective script, allowing you to stand away from the market during flat periods and trading with the trend during exciting periods.
Access to the script will be grated for 10$ of most low-fee cryptocurrencies, as well as BTC. If you're interested reach out to me through TradingView or, alternatively, contact @overttheraibow through Telegram.
If there's enough demand for it, I will also create a strategy version of this study which will be given for free to those who purchased the script. As always, maximum 250 places available.
Good luck!
Tensor CloudIntroducing the Tensor Cloud. This is probably the best indicator I've come up with so far. I'm really proud of it. Ichimoku is a brilliant system. It's been around for over half a century and I praise Goichi Hosoda for his brilliant work. However, it's time for something new. I love math and this indicator really showcases that. The Tensor Cloud is an indicator of its own. It is not related to Ichimoku at all. The only thing they have in common is that they both form clouds. The maths in Tensor Cloud are 100% apart.
The Tensor Cloud is mostly comprised of some special forms of linear regression. Let's do a rundown.
Future Span A (Green)
This is one predictor using a linear regression technique. Future Span A is one of the two lines that makes up a Tensor Cloud. From here on out it will traditionally be colored green. It can be used as both a predictor on its own and comprising the Tensor Cloud. This can also be viewed as sort of a long signal when crossing up Future Span B. This line can also be used to help identify levels of support and resistance.
Future Span B (Red)
This is another form of linear regression meant specifically to work alongside Future Span A. This is the second line that comprises a Tensor Cloud. From here on out it will traditionally be colored red. It can be used both as a predictor on its own and comprising the Tensor Cloud. This can also be viewed as sort of a short signal when crossing down through Future Span A. This line can also be used to help identify levels of support and resistance.
Safe (White)
The Safe is a moving average taken of Future Span A and Future Span B. It is highly predictive. From here on out it will traditionally be colored white.
Tip (Fuchsia)
This is yet another form of regression and is highly predictive. The Tip can also be used to help judge trend strength and probability of reversal. More study is of course needed. More on that later in this description. From here on out it will traditionally be colored fuchsia. This line can also be used to help identify levels of support and resistance.
The Tensor Cloud
The space between Future Span A and Future Span B is shaded in green or red, depending on which Future Span is on top. If Future Span A is on top, the Tensor Cloud will be green. This is considered a long signal. If Future Span B is on top, the Tensor Cloud will be colored red. This is a short signal. Attention should also be given to other factors such as:
The position of price in relation to the Tensor Cloud (Under, inside or above).
The position of Tip in relation to the Tensor Cloud.
Crosses of Future Span A and Future Span B.
Tensor Twist
Whenever Future Span A and Future Span B cross (In either direction), this is called a Tensor Twist. If Future Span A is crossing up, this is a long Tensor Twist. If Future Span B is crossing up, this is a short Tensor Twist.
Closing Summary
Much study needs to be done. This is a brand new technique. It's up to all of you to help figure out the best ways to use it. I may still add other components to this indicator but it's pretty solid as is. You will notice that the two integer inputs are set to 27. Twenty-seven is a very important number in mathematics. The details of that are beyond the scope of this description but from here on out, the traditional setting for those will be 27. You will notice that I am not yet releasing the source code to this indicator. For now, it will remain protected. Once I have enough feedback and we're all happy with the final result, I will release the code for the world to have. I have no wish of keeping this closed-source (As profitable as that might be). I just want it to help as many people as possible.
Please share this on social media so we can attract as many testers to give feedback as possible. For publishing this for free, that's all I ask in return. That way it will be as solid as possible when I release the source code.
Enjoy!
MACD of Linear Regression Slope Indicator I used MACD to find peak and trough points in the Linear Regression Slope
Linear Tendency FollowerLinear Trend Follower follows 'source' trend using lines within a number of periods ('length') using the last n periods source variation divided by 'length' as line slope. It is delayed by 'length' periods.
lin.reg.s_420Hey all,
Snoop here with another script this one is linear regression slope analysis;
I used a base skeleton script of /u/ucsgears before adding some other cumulative log filtering and average customization functions I like :)
If you have success with this script feel free to buy me a coffee through my bitcoin address :)
Appreciate the love I get from the community! Thanks all and happy trading!
-Snoop
Momentum Linear RegressionThe original script was posted on ProRealCode by user Nicolas.
This is an indicator made of the linear regression applied to the rate of change of price (or momentum). I made a simple signal line just by duplicating the first one within a period decay in the past, to make those 2 lines cross. You can add more periods decay to made signal smoother with less false entry.
LWMA w/ Color ChangeLinear Weighted MA that changes colors based on slope.
Green = slope up from last bar
Yellow = slope is 0 from last bar
Red = slope down from last bar
This time with the ability to change the period.
LWMA w/ Color ChangeLinear Weighted MA that changes colors based on slope.
Green = slope up from last bar
Yellow = slope is 0 from last bar
Red = slope down from last bar
Function 2 Point Line using UNIX TIMESTAMP V1experimental:
draws a line from 2 vectors(price, time)
update:
reformatted the function,
added automatic detection of the period multiplier by approximation(gets a bit goofy with stocks/week time),
example using timestamp() function.
offsetting is still bugged, i cant find a way around it atm.