cryptographic1

Linear Regression Slope (Actual)

Linear Regression Slope is useful for determining if a trend is strengthening or weakening.

This is a true calculation of linear regression slope rather than a numerical differentiation calculated by subtracting previous linear regression value from current linear regression value. TradingView does not include a linear regression slope formula, but the built-in formula for linear regression does include the offset parameter which multiplies linreg slope as shown below:

linreg(source, length, offset) -> linreg = intercept + slope * (length - 1 - offset)

So therefore we can calculate linreg slope by subtracting a linreg with offset 0 from a linreg with offset 1. Easy peasy :) Much cleaner and smoother than taking the difference between current linreg value and previous linreg value also.

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?