mult1 = input.float(3, "Upper Deviation Threshold ")
[c,o,v] = request.security_lower_tf(syminfo.tickerid, lowerTimeframeInput, [close,open,volume])
sell = array.new_float()
buy = array.new_float()
if c.size() > 0
for i = 0 to c.size() - 1
dir = c.get(i) > o.get(i) ? 1 : -1
if dir == 1
buy.push(v.get(i) * c.get(i))
sell.push(0)
if dir == -1
sell.push(v.get(i) * c.get(i))
buy.push(0)
den(type) =>
switch type
"1 Billion" => 1000000000
"1 Million" => 1000000
"1 Thousand" => 1000
"None" => 1
sellers = sell.sum()/den(denom)
buyers = buy.sum()/den(denom)
deviation = math.sqrt(ta.sma(math.pow(buyers-sellers,2), 70))
buy = ta.crossover(buyers, deviation * mult1)