//@version=4
study(title="ema-sma", shorttitle="ema-sma + vol")
src = close
length = 9 //input(9, minval=1, title="short ema")
lensma = 17 //input(17, title="long sma")
vol = volume
vm = 100 * ((sma(vol, length) - sma(vol, length)[4]) / sma(vol, length)[4])
vvm = 100 * sma((vm - vm[1]) / vm[1], 3)
osc = sma(ema(src, length) - sma(src, lensma), 3)
sig = (osc + 2 * osc[1] + 2 * osc[2] + osc[3]) / 6
cc = osc > 0 ? color.lime : osc < 0 ? color.red : na
cut = abs(vvm / 8) > abs(sma(vvm, 5)) ? osc / 0.7 : na
cv = cut > 0 ? color.aqua : color.orange
si = plot(sig, color=cc, title="Sig")
duml = plot(osc > sig ? osc : sig, style=plot.style_circles, linewidth=0, color=color.gray)
os = plot(osc, color=cc, linewidth=2, title="ROC")
fill(si, duml, color=color.green, transp=50)
fill(os, duml, color=color.red, transp=50)
hline(0, title="Zero Line", color=color.white, linewidth=2)
colorebe = #0000ff
hline(0, title="Zero Line", color=#0000ff, linewidth=2, linestyle=hline.style_solid)
plot(cut, color=cv, style=plot.style_columns, linewidth=2, transp=60, title="Istogramma")