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 anchoredAP = TotalSum(if postAnchorDate and postAnchorTime then ((high+low+close)/3) else 0)/TotalSum(if postAnchorDate and postAnchorTime then volume else 0);
anchoredAP .setStyle(Curve.Firm);
anchoredAP .SetLineWeight(3);
anchoredAP .SetDefaultColor(Color.Cyan);
#AddChartBubble(yes,close, revisedDate, color.yellow);