z_score
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © crashout75

//@version=5
indicator("z_score")

window = input(40, title="window")
vSMA = ta.sma(close,window)
vSTDDEV = ta.stdev(close,window,true)

plot((close-vSMA)/vSTDDEV,title="Z-SCORE", style=plot.style_columns, color=color.new(color.blue,50))

h0=plot(10, color=color.new(color.green,50), title ="z=10")
h1=plot(2, color=color.new(color.green,50), title ="z=2")
h2=plot(1, color=color.new(color.green,50), title ="z=1")
h3=plot(0, color=color.new(color.blue,50), title ="z=0")
h4=plot(-1, color=color.new(color.green,50), title ="z=-1")
h5=plot(-2, color=color.new(color.green,50), title ="z=-2")
h6=plot(-10, color=color.new(color.green,50), title ="z=-10")

fill(h0, h1, color=color.new(color.green, 70), title="STRONG BUY")
fill(h1, h2, color=color.new(color.green, 85), title="BUY")
fill(h2, h4, color=color.new(color.gray, 90), title="NO TRADE")
fill(h4, h5, color=color.new(color.green, 85), title="SELL")
fill(h5, h6, color=color.new(color.green, 70), title="STRONG SELL")
//tweak