lag2 = input(lag2)
outslow = linreg(src, len2, offset)
a few ticks of lag will improve your results generally, prevent some false signals. Also, 100/150 settings you are using are generally pretty good on 15 minute ticks, try in the range of 25/35 for hourly ticks. Cheers :)
May I ask, what do you think is the best/a better way of using the linear regression line? I was thinking of using it as a trend indicator (based on what direction it's moving, so something like: uptrend = lsma > lsma.
What are your thoughts on it's potential uses?