declare upper;
script x {
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) ;
input count = 5;
input extend = 5;
def c = if thisDay == count and SecondsFromTime(1600) < 0 then Double.NaN else if thisDay == count and SecondsFromTime(1600) == 0 then close else c[1];
def CDPext = if thisDay == count then c else CDPext[1];
input show_all_on_today = yes;
plot CDP = if show_all_on_today == yes and thisDay == 0
and Between(thisDay, count - extend, count) and CDPext
then CDPext
else if show_all_on_today == no and thisDay >= 0
and Between(thisDay, count - extend, count) and CDPext
then CDPext
else Double.NaN ;
}
input show_all_on_today = yes;
input extend = 5;
plot cdp1 = x(count = 1, extend = extend, "show all on today" = show_all_on_today);
plot cdp2 = x(count = 2, extend = extend, "show all on today" = show_all_on_today);
plot cdp3 = x(count = 3, extend = extend, "show all on today" = show_all_on_today);
plot cdp4 = x(count = 4, extend = extend, "show all on today" = show_all_on_today);
plot cdp5 = x(count = 5, extend = extend, "show all on today" = show_all_on_today);
cdp1.SetDefaultColor(Color.YELLOW);
cdp1.SetLineWeight(2);
cdp1.SetPaintingStrategy(PaintingStrategy.DASHES);
cdp2.SetDefaultColor(Color.YELLOW);
cdp2.SetLineWeight(2);
cdp2.SetPaintingStrategy(PaintingStrategy.DASHES);
cdp3.SetDefaultColor(Color.YELLOW);
cdp3.SetLineWeight(2);
cdp3.SetPaintingStrategy(PaintingStrategy.DASHES);
cdp4.SetDefaultColor(Color.YELLOW);
cdp4.SetLineWeight(2);
cdp4.SetPaintingStrategy(PaintingStrategy.DASHES);
cdp5.SetDefaultColor(Color.YELLOW);
cdp5.SetLineWeight(2);
cdp5.SetPaintingStrategy(PaintingStrategy.DASHES);
input showbubbles = yes;
input bubblemover = 5;
def b = bubblemover;
def b1 = b + 1;
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), cdp1[b], "C1", Color.WHITE);
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), cdp2[b], "C2", Color.WHITE);
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), cdp3[b], "C3", Color.WHITE);
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), cdp4[b], "C4", Color.WHITE);
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), cdp5[b], "C5", Color.WHITE);