Hey!

I have been trying to blend two indicators but am having trouble getting them to work correctly. Thanks for taking the time to open this thread!

I looked around and found many interday studies of the standard deviation from the vwap, but had trouble finding a z score of an anchored vwap. I have been trying to use the VWAP Zscore (which is really intraday) from this thread:

https://usethinkscript.com/threads/z-score-distance-from-vwap-for-thinkorswim.602/
Code:

```
# Intraday VWAP Zscore
# Mobius
# 06.10.2019 Chat Room Request
declare lower;
def RTH = GetTime() >= RegularTradingStart(GetYYYYMMDD()) and
GetTime() <= RegularTradingEnd(GetYYYYMMDD());
def n = if RTH and !RTH[1]
then 1
else if RTH
then n[1] + 1
else n[1];
def Avg = (fold i = 0 to n
with s
do s + getValue(close, i)) / n;
def VWAP_ = (fold ii = 0 to n
with ss
do ss + getValue(vwap, ii)) / n;
def StDev = Sqrt((fold iii = 0 to n
with sss = 0
do sss + Sqr(Avg - getValue(close, iii))) / n);
plot Zscore = (close - VWAP_) / StDev;
plot "0" = if isNaN(close) then double.nan else 0;
"0".SetDefaultColor(Color.white);
plot "1SD" = if isNaN(close) then double.nan else 1;
"1SD".SetDefaultColor(Color.Green);
plot "2SD" = if isNaN(close) then double.nan else 2;
"2SD".SetDefaultColor(Color.Green);
plot "-1SD" = if isNaN(close) then double.nan else -1;
"-1SD".SetDefaultColor(Color.Red);
plot "-2SD" = if isNaN(close) then double.nan else -2;
"-2SD".SetdefaultColor(Color.Red);
AddCloud(0, Zscore, color.red, color.green);
# End Code
```

And to replace the VWAP with an anchored VWAP with adjustable date and time from this thread:

https://usethinkscript.com/threads/anchored-vwap-indicator-for-thinkorswim.171/
Code:

```
input anchorDate = 20200422;
input anchorTime = 2030;
def tradeStartEST = 0930;
def tradeEndEST = 1600;
def inPeriod = if SecondsTillTime(tradeStartEST) <= 0 and SecondsTillTime(tradeEndEST) > 0 then 1 else 0;
def revisedDate = if SecondsTillTime(anchorTime)<=0 and !inPeriod then anchorDate+1 else if SecondsTillTime(anchorTime)<=0 and inPeriod then anchorDate else anchorDate;
def postAnchorDate = if GetYYYYMMDD() >= revisedDate then 1 else 0;
def postAnchorTime = if SecondsTillTime(anchorTime) <= 0 then 1 else 0;
plot anchoredVWAP = TotalSum(if postAnchorDate and postAnchorTime then ((high+low+close)/3)*(volume) else 0)/TotalSum(if postAnchorDate and postAnchorTime then volume else 0);
anchoredVWAP.setStyle(Curve.Firm);
anchoredVWAP.SetLineWeight(3);
anchoredVWAP.SetDefaultColor(Color.Cyan);
#AddChartBubble(yes,close, revisedDate, color.yellow);
```

I have tried simply changing out VWAP with achoredVWAP or changing RTH to try to emulate the time change, but I appear to be lost. I just want a lower indicator with an oscillator showing this score of the anchored vwap but the math and different codes have me a bit turned around. I would be extremely grateful for anyone's help or input! Thanks!