#_52_Week_HL_Bubbles
# @joshua code - Just added bubbles
# The bubbles work on primarily daily and weekly charts and the bars where these occur have to be visible on the chart for these to appear.
# The labels seem to work intraday with most aggregations with adequate timeframes set. For example, on a 1m chart, a 30 day timeframe seemed to work.
input showbubbles = yes;
input showlabels = yes;
def LastBar = HighestAll(if !IsNaN(close) then BarNumber() else Double.NaN);
def LastHigh = HighestAll(if BarNumber() == LastBar then Highest(high(period = AggregationPeriod.WEEK), 52) else Double.NaN);
def Day;
def Month;
def Year;
if high == LastHigh {
Day = GetDayOfMonth(GetYYYYMMDD());
Month = GetMonth();
Year = GetYear();
} else {
Day = Day[1];
Month = Month[1];
Year = Year[1];
}
AddLabel(showlabels, "High is: " + LastHigh + " on " + Month + "/" + Day + "/" + AsPrice(Year), Color.LIGHT_GREEN);
AddChartBubble(showbubbles and high == LastHigh, high, "HH: " + AsDollars(LastHigh) + "\n" + Month + "/" + Day + "/" + AsPrice(Year), Color.LIGHT_GREEN);
##########################
def LastLow = HighestAll(if BarNumber() == LastBar then Lowest(low(period = AggregationPeriod.WEEK), 52) else Double.NaN);
def DayL;
def MonthL;
def YearL;
if low == LastLow {
DayL = GetDayOfMonth(GetYYYYMMDD());
MonthL = GetMonth();
YearL = GetYear();
} else {
DayL = DayL[1];
MonthL = MonthL[1];
YearL = YearL[1];
}
AddLabel(showlabels, "Low is: " + LastLow + " on " + MonthL + "/" + DayL + "/" + AsPrice(YearL), Color.LIGHT_RED);
AddChartBubble(showbubbles and low == LastLow, low, "LL: " + AsDollars(LastLow) + "\n" + MonthL + "/" + DayL + "/" + AsPrice(YearL), Color.LIGHT_RED, no);