A regression line is simply a single line that best fits the data.
In the pinescript you can plot a linear regression line using the linreg function.
Here i share the entire calculation of the linear regression line, you are free to take the code and modify the functions in the script for creating your own kind of filter.