#Define Days
def ymd = GetYYYYMMDD();
def candles = !IsNaN(close);
def capture = candles and ymd != ymd[1];
def dayCount = CompoundValue(1, if capture then dayCount[1] + 1 else dayCount[1], 0);
def thisDay = (HighestAll(dayCount) - dayCount) ;
#Define Regular Trading Hours
def rth = Between(GetTime(), RegularTradingStart(GetYYYYMMDD()), RegularTradingEnd(GetYYYYMMDD()));
#Define Number of Bars based upon Chart Aggregation
def bars = 390 / (GetAggregationPeriod() / 60000);
#Define RTH volume for Prior Day to Current Day
def rthvol = if thisDay == 1 and rth then rthvol[1] + volume else rthvol[1];
#Plot Prior Day's RTH Average Volume on Today's Chart
plot prior_rth_volume = rthvol / bars;
AddLabel(1, "Prior Day Total RTH Volume: " + rthvol + " / " + bars + " Bars = Average Volume: " + round(prior_rth_volume,0), color.cyan);