input showtodayonly = yes;
input agg = AggregationPeriod.FIVE_MIN;
input begin = 0930;
input end = 1030;
def c = close(period = agg);
def o = open(period = agg);
def range = SecondsFromTime(begin) >= 0 and SecondsTillTime(end) >= 0;
def hrange = if range[1] == 0 and range
then Max(c, o)
else if range
then Max(Max(c, o), hrange[1])
else if SecondsFromTime(1600) <= 0
then hrange[1]
else Double.NaN;
def lrange = if range[1] == 0 and range
then Min(c, o)
else if range
then Min(Min(c, o), lrange[1])
else if SecondsFromTime(1600) <= 0
then lrange[1]
else Double.NaN;
def cstart = if range[1] == 0 and range
then c
else if SecondsFromTime(1600) <= 0
then cstart[1]
else Double.NaN;
def cend = if range[-1] == 0 and range
then c
else if SecondsFromTime(1600) <= 0
then cend[1]
else Double.NaN;
input showlabel = yes;
AddLabel(showlabel, begin + "-" + AsPrice(end) + " H:" + AsDollars(hrange) + " L: " + AsDollars(lrange) + " CS: " + AsDollars(cstart) + " CE: " + AsDollars(cend), Color.YELLOW);
input showplot = yes;
plot xhrange = if !showplot or (showtodayonly and !IsNaN(c))
then Double.NaN
else hrange;
plot xlrange = if !showplot or (showtodayonly and !IsNaN(c))
then Double.NaN
else lrange;
plot xcstart = if !showplot or
(showtodayonly and !IsNaN(c))
then Double.NaN
else cstart;
plot xcend = if !showplot or
(showtodayonly and !IsNaN(c)) or
(showtodayonly and GetDay() == GetLastDay() and SecondsTillTime(end) > 0)
then Double.NaN
else cend;
xhrange.SetPaintingStrategy(PaintingStrategy.DASHES);
xlrange.SetPaintingStrategy(PaintingStrategy.DASHES);
xcstart.SetPaintingStrategy(PaintingStrategy.DASHES);
xcend.SetPaintingStrategy(PaintingStrategy.DASHES);
input showbubbles = yes;
input bubblemover = 3;
def b = bubblemover;
def b1 = b + 1;
AddChartBubble(showbubbles and IsNaN(c[b]) and !IsNaN(c[b1]), xhrange[b], "H", xhrange.TakeValueColor());
AddChartBubble(showbubbles and IsNaN(c[b]) and !IsNaN(c[b1]), xlrange[b], "L", xlrange.TakeValueColor());
AddChartBubble(showbubbles and IsNaN(c[b]) and !IsNaN(c[b1]), xcstart[b], "CS", xcstart.TakeValueColor());
AddChartBubble(showbubbles and IsNaN(c[b]) and !IsNaN(c[b1]), xcend[b], "CE", xcend.TakeValueColor());
;