I’ve read this link and the following:
Intercept = average[period](close) - Slope * average[period](barindex)
But it seems it is not correct since the value of intercept is quite different than that from TradinView or other platforms.
Hello,
There is no native “Intercept” instruction in Pine Script, TradingView only provides ta.linreg(source, length, offset), which returns the value of the regression line itself, not the intercept as a separate output. If you want the actual intercept, you have to calculate it manually with the least squares formulas, same as we do in ProBuilder.
What people call LRI (Linear Regression Intercept) on TradingView is just a community script, not a built in function, and it uses the same math you already tried, here are 2 topics about how to calculate intercept in ProBuilder (mostly use to test breakout of trendlines or patterns such as triangles:
Etendre DRAWRAY sur X barres
lignes de support resistance oblique dans proorder
Let us know if the numbers match once you try this.
BTW, I just translated this intercept code from a TV translation query I found out in the forum from years ago:
Conversion of regression intercept indicator