```
# Intraday VWAP Zscore
declare lower;
input price = close;
input length = 20;
#calc_zvwap(pds) =>
# mean = sum(volume*close,pds)/sum(volume,pds)
def mean = Sum(Volume*Close, length)/Sum(Volume, length);
# vwapsd = sqrt(sma(pow(close-mean, 2), pds) )
def vwapsd = Sqrt(Average(Power(Close-mean, 2), length));
# (close-mean)/vwapsd
def zScore = (Close-mean)/vwapsd;
####
plot "0" = if IsNaN(close) then Double.NaN else 0;
"0".SetDefaultColor(Color.GRAY);
plot "1SD" = if IsNaN(close) then Double.NaN else 1;
"1SD".SetDefaultColor(Color.WHITE);
def "2SD" = if IsNaN(close) then Double.NaN else 2;
def "2.5SD" = if IsNaN(close) then Double.NaN else 2.5;
AddCloud("2SD", "2.5SD", Color.RED, Color.GREEN);
plot "-1SD" = if IsNaN(close) then Double.NaN else -1;
"-1SD".SetDefaultColor(Color.WHITE);
def "-2SD" = if IsNaN(close) then Double.NaN else -2;
def "-2.5SD" = if IsNaN(close) then Double.NaN else -2.5;
AddCloud("-2SD", "-2.5SD", Color.RED, Color.GREEN);
Plot zscorevwap = zscore;
AddCloud(0, Zscore, Color.RED, Color.GREEN);
# End Code
```