**Note :**

*This is my very first published script on trading view & from brainstorming an idea to developing to the finched product it was imperative to me for the indiactor and every one of its features to be of some meaningfull use. If you like the idea of statsitics being able to predict future prices in the market then this indicator may be usefull in your trading arsenal.*

Introduction :

Lagging Session Regression Channel (LSRC) is a statistical trend analysis indicator that "laggs" the market by the user defined session, by defualt a day, by doing so the indicator leverges the ability of simple linear regression to predict future asset price.(This can be used on any asset in any market in any time frame)

Options & inputs :

- Bar regression lookback :

The value of bars back from the lats session change, if the seesion time is equivelnt to the the chart timefrmae then the regression line will not lag price, i.e it will act as a stantdard lineer regression channel chnaging on evrey last confimred bar.

- Standard Deviation lookback :

The value of bars from the last session change to cacluate the unbiased standard deviation, The lookback can be set to > or < the regression lookback to cauture > or < less asset volatility . (note this is the same as the residual standard deviation)

- Predicted price at nth bar :

if you whant to know the predicted close price value at any given point in the regression and to the RHS of the regression.

- Regression Line colors group :

Changes the colors of each plotted line.

- OLS Line color : is only changeable when trend color is set to false / unticked.

- Visable deviations group :

Plots the lines that you want on chart, e.g if "Show DEV1" and "Sow DEV SUB1" are the only inputs ticked then they will be the only lines ploted along with the simple linear regression line.

- Regression Line Dynamics group :

All inputs in this group change the regressions calculations given the bar lookback is constant / the same.

- Trend color : if set too true, when the close of the proceding real time bar is greater than the simple linear regression line from the last confimred session the line will be colored green, if otherwise the close is below the simple linear regression line the line will be colored red.

- Extend regression line :

This is the same chart image as seen on the publication chart image but with Extend regression line set to true, this allows the trader to test the valdity of the regression and how well it predicts future price, as seen on the M15 chart of BTCUSD above the indicator was pritty good at doing this.

- Standard deviation channel source :

Source for standard deviation to be calculated on. note if this is set to a varible other than the close then this will no longer be the resdiaul standard deviation, as of now "LSRC 1.0" the regression uses only the close for y / predicted values.

- Time elasped unitl next regression calculation :

The session time until the next LSRC will be calculated and plotted

Label LSRC stats :

- STAN DEV : the standard deviation used to cacluateed the deviation channels

- MIN : The lowest price across the regression

- MAX : The highest price across the regression

- n bars above dev 1 : The number of bars that closed above the first standard deviation channel across the entire regression calculation

- n bars below sub dev1 : The number of bars that closed below the first standard deviation channel.

- Regression Price : The output of "Predicted price at nth bar" input.

Hope you find this usefull !

I will continue too try improve this script and update it accordingly.

LSRC V2

Hello Traders !

I have updated the existing LSRC, updates include :

- Trend Trailing Regression Lines from priviois sessions, I took inpiration from @LoneomeTheBlue Linear Regression Channel

- R^2 feature, this is a bounded statistic ranging from 0 - 1, This statistic measures the accuracy of the regression, more formaly.

"The coefficient of determination, or R^2 is a measure that provides information about the goodness of fit of a model. In the context of regression it is a statistical measure of how well the regression line approximates the actual data. It is therefore important when a statistical model is used either to predict future outcomes"

- Max bars back, from 500 - 1000

- general bug fixes

In conclusion, I belive this is now one they best linear regression lines in trading view, i will continue to update the script and am open to any ideas, Enjoy !!!

Hello Traders !

I have updated the existing LSRC, updates include :

- Trend Trailing Regression Lines from priviois sessions, I took inpiration from @LoneomeTheBlue Linear Regression Channel

- R^2 feature, this is a bounded statistic ranging from 0 - 1, This statistic measures the accuracy of the regression, more formaly.

"The coefficient of determination, or R^2 is a measure that provides information about the goodness of fit of a model. In the context of regression it is a statistical measure of how well the regression line approximates the actual data. It is therefore important when a statistical model is used either to predict future outcomes"

- Max bars back, from 500 - 1000

- general bug fixes

In conclusion, I belive this is now one they best linear regression lines in trading view, i will continue to update the script and am open to any ideas, Enjoy !!!