#This displays the bar's value at the 4hr agg prior to the current 4hr bar
input Agg = AggregationPeriod.FOUR_HOURS;
def data = high(period = Agg);
def data1 = high(period = Agg)[1];
AddLabel(1, "High @prior 4hr agg candle: " + data1, Color.YELLOW);
#x=last bar being displayed
#xx= high @bar 4hrs before x
def x = if !IsNaN(close) and IsNaN(close[-1]) then BarNumber() else 0;
plot xx = if BarNumber() == (HighestAll(x) - 4 * 60 / (GetAggregationPeriod() / 60000)) then high else Double.NaN;
xx.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
AddLabel(1, "High 4hrs ago based upon chart agg: " + HighestAll(xx), Color.WHITE);
#######
#Example Time_Gettime
#Sleepz 20210315
#Usethinkscript request
#Time Stamp based upon Gettime and RegularTradingStart. Choose timezone
input timezone = {default "ET", "CT", "MT", "PT"};
def starthour = (if timezone == timezone."ET"
then 9
else if timezone == timezone."CT"
then 8
else if timezone == timezone."MT"
then 7
else 6) ;
def hour = Floor(((starthour * 60 + 30) + (GetTime() - RegularTradingStart(GetYYYYMMDD())) / 60000) / 60);
def minutes = (GetTime() - RegularTradingStart(GetYYYYMMDD())) / 60000 - ((hour - starthour) * 60 + 30) + 60;
AddChartBubble(IsNaN(close[-1]), low, "Time:" + hour + ":" + (if minutes < 10 then "0" else "") + minutes, Color.WHITE, no);
AddChartBubble(IsNaN(close[-1]), low, "Time 4hrs ago :" + (hour - 4) + ":" + (if minutes < 10 then "0" else "") + minutes, Color.WHITE, no);