```
# MAC-Z VWAP Indicator by LazyBear
# conversion by @Joshua 11/2021
input fastLength = 12;
input slowLength= 25;
input signalLength = 9;
input lengthz = 20;
input lengthStdev = 25;
input A = 1.0;
input B = 1.0;
input useLag = no;
input gamma = 0.02;
def source = close;
script Nz {
input Num = 0;
plot Nz = if isNaN(Num) then 0 else Num;
}
script calc_laguerre {
input s = 0;
input g = 0;
def l0 = (1 - g)*s+g*nz(l0[1]);
def l1 = -g*l0+nz(l0[1])+g*nz(l1[1]);
def l2 = -g*l1+nz(l1[1])+g*nz(l2[1]);
def l3 = -g*l2+nz(l2[1])+g*nz(l3[1]);
plot calc_laguerre = (l0 + 2*l1 + 2*l2 + l3)/6;
}
script calc_zvwap {
input pds = 0;
def mean = sum(volume*close,pds)/sum(volume,pds);
def vwapsd = sqrt(simpleMovingAvg(power(close-mean,2),pds));
plot calc_zvwap = (close-mean)/vwapsd;
}
def zscore = calc_zvwap(lengthz);
def fastMA = simpleMovingAvg(source, fastLength);
def slowMA = simpleMovingAvg(source, slowLength);
def macd = fastMA - slowMA;
def macz_t = zscore*A+ macd/stdev(source, lengthStdev)*B;
def macz = if uselag then calc_laguerre(macz_t,gamma) else macz_t;
def signal=simpleMovingAvg(macz, signalLength);
def hist = macz-signal;
plot Histo = Hist;
Histo.SetDefaultColor(color.red);
Histo.setPaintingStrategy(paintingStrategy.HISTOGRAM);
plot MackLine = MacZ;
MackLine.SetDefaultColor(color.Green);
plot Sig = Signal;
Sig.SetDefaultColor(color.orange);
```