BeasleySavage

Regression Line (OLS) w/Residual Bands - Beasley Savage

Plots linear regression "line of best fit" for a given source and length. Also plots the standard deviation of residuals as upper and lower bands. For some reason it's not plotting the lines exactly where the values are, so I wouldn't recommend using it as a purely visual indicator, but it could be used in strategies. A quick implementation of a strategy buying when the close crossed over the lower band and selling when close crossed under the upper band resulted in ~60-70% trade accuracy, not taking into account commission/slippage.

If anyone knows how to fix the lines not plotting accurately please let me know :)

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?