EMA Oscilator [Azzrael]
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Azzrael

//@version=5
indicator("EMA Oscilator by Azzrael", overlay=false)

ema_length = input.int(9, "EMA Period", minval=2, step=1)
limit = input.float(2, "Limit Factor", minval=1, step=0.1, maxval=10)

v = close - ta.ema(close, ema_length)
dev = ta.stdev(v, ema_length)
dev_limit = dev*limit


// Plot Standard Deviations
plot(dev, "Std Dev Green", color=color.new(color.blue, 70))
plot(dev*-1, "Std Dev Red", color=color.new(color.orange, 70))
plot(dev_limit, "Std Dev Green 2", color=color.new(color.green, 80))
plot(dev_limit*-1, "Std Dev Red 2", color=color.new(color.orange, 80))


// Plot Oscilator Value
color = v >= dev_limit ? color.green :
 v > 0 ? color.new(color.blue, 80) :
 v > dev_limit*-1 ? color.new(color.orange, 80):
 color.red 

plot(v, "EMA Osc", style=plot.style_histogram, color=color)
