For coders: possibilities to manipulate Linear Regression?

 

Obviously length and offset can me changed, but I was thinking about changing the curve "on-the-go". Is that even possible?

Why? When a fast trend reaches its peak, linear regression curve will cut it nicely, but if an opposite trend goes fast too (and right after previous peak), linear curve will not manage to turn around and follow that new trend properly.

Thoughts?

Reason: