Linear Channel - Scalp Strategy 15M
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TradingAmmo

//@version=4
strategy("Linear Channel", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.075, currency='USD')
startP = timestamp(input(2017, "Start Year"), input(12, "Month"), input(17, "Day"), 0, 0)
end   = timestamp(input(9999, "End Year"),  1, 1,  0, 0)
_testPeriod() =>
    iff(time >= startP and time <= end, true, false)

//linreg
length = input(55)
linreg = linreg(close, length, 0)
plot(linreg, color=color.white) 

//calc band
Value = input(-2)
sub = (Value/100)+1
Band2 = linreg*sub
plot(Band2, color=color.red)

//HMA as a filter
HMA = input(400, minval=1)  
plot(hma(close, HMA), color=color.purple)  

long_condition = close <  Band2  and hma(close, HMA) < close and _testPeriod()
strategy.entry('BUY', strategy.long, when=long_condition)  
 
short_condition =  close > linreg
strategy.close('BUY', when=short_condition)
