Infiten's Regressive Trend Channel 
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © spiritualhealer117

//@version=4
study("Regression Estimates")
len = input(title="Extreme Length", type=input.integer, defval=14)
len2 = input(title="Regression Length", type=input.integer, defval=14)

offset = input(title="Plot Offset", type=input.integer,defval=0)

low_forecast = linreg(lowest(low,len),len2,0)
high_forecast = linreg(highest(high,len),len2,0)
mid_forecast = linreg(sma((close+open)/2,len),len2,0)

plot(low_forecast, offset=offset, color=color.red, style=plot.style_circles)
plot(high_forecast, offset=offset, color=color.green, style=plot.style_circles)
plot(mid_forecast, offset=offset, color=color.gray, style=plot.style_circles)
plotcandle(close, high_forecast, low_forecast, mid_forecast, title = 'LRE', color = mid_forecast < close ? color.green : color.red, wickcolor = color.black)