A regression line is simply a single line that best fits the data.
In the pinescript you can plot a line using the linreg function.
Here i share the entire calculation of the line, you are free to take the code and modify the functions in the script for creating your own kind of filter.
Hope you enjoy :)
Become a Patreon and get access to exclusive technical indicators!
You can also check out some of the indicators I made for luxalgo : https://www.tradingview.com/u/LuxAlgo/#published-scripts
I am trying to us the homodyne discriminator from ehlers ideal rsi, to set a variable length based on the price cycle for some of my indicators. this does work but the pinescript standard functions do not like dealing with a variable length, so i normally have to code out the functions... i am having such a problem with linreg, so finding your formula is very useful but it has the stock function 'sma' stdev' and 'correlation' which stops the code dead...
I wondered if you might be able to write out the stdev and the correlation functions in pinescript, if you have time.
Let me know what you think