Linear Regression Curve in Pine Script of www.tradingview.com

in #tradingview7 years ago (edited)

Please find below code for 20 Period Linear Regression Curve Fitting. Test it out in the Pine Editor of https://www.tradingview.com. More details follow as time permits!

//@version=3
study(title="LinearRegressionCurve20", shorttitle="LRC20", overlay=true)
src = close
len = input(defval=20, minval=1, title="Length")
offset = 0
out = linreg(src, len, offset)
plot(out, color=purple, linewidth=2)
//END

The Screenshot of 20 Period Linear Regression Curve(Purple line) on 1 day candles of BTSUSD(Poloniex):
Jan19_2017_BTSUSD_1DAY_20PeriodLinearRegressionCurve.png

Legal Disclaimer: I did not get bribed to write here and I am not seeking to get into insider favors. I wrote here so I get replies from fellow viewers to educate myself and for my daily expenses. Hence, if anyone uses this post for making their decisions, I am not responsible for any failures incurred.

If you found this blog post interesting and edifying please follow, upvote, resteem.

ETH Wallet - 0x0450DCB7d4084c6cc6967584263cF6fBebA761D1
BTS Wallet - chip-maker

NEO Wallet - AUdiNJDW7boeUyYYNhX86p2T8eWwuELSGr
NEOWalletPublicAddress.png