def isUpCloseCandle = close > open;
def count = if !isUpCloseCandle
then 0 else
if !isUpCloseCandle[2] and isUpCloseCandle[1] and isUpCloseCandle and low[1] > low
then 2 else
if !isUpCloseCandle[1] and isUpCloseCandle and count[1] == 0
then 1
else 0;
def lowlength = if count == 2
then low else
if count[-1] != 2 and count == 1
then low
else lowlength[1];
input test = no;
AddChartBubble(test and between(count,1,2),low, count, Color.YELLOW, no);
def candles = !IsNaN(close);
def capture = candles and lowlength != lowlength[1];
def xCount = CompoundValue(1, if capture then xCount[1] + 1 else xCount[1], 0);
def x = (HighestAll(xCount) - xCount) + 1;
def upclose1 = if IsNaN(lowlength)
then upclose1[1] else
if x == 1
then lowlength
else upclose1[1];
plot u1 = upclose1;
u1.SetDefaultColor(Color.GREEN);
u1.SetPaintingStrategy(PaintingStrategy.DASHES);
u1.SetLineWeight(1);
def upclose2 = if IsNaN(lowlength)
then upclose2[1] else
if x == 2
then lowlength
else upclose2[1];
plot u2 = upclose2;
u2.SetDefaultColor(Color.GREEN);
u2.SetPaintingStrategy(PaintingStrategy.DASHES);
u2.SetLineWeight(1);
def upclose3 = if IsNaN(lowlength)
then upclose3[1] else
if x == 3
then lowlength
else upclose3[1];
plot u3 = upclose3;
u3.SetDefaultColor(Color.GREEN);
u3.SetPaintingStrategy(PaintingStrategy.DASHES);
u3.SetLineWeight(1);
def upclose4 = if IsNaN(lowlength)
then upclose4[1] else
if x == 4
then lowlength
else upclose4[1];
plot u4 = upclose4;
u4.SetDefaultColor(Color.GREEN);
u4.SetPaintingStrategy(PaintingStrategy.DASHES);
u4.SetLineWeight(1);
def upclose5 = if IsNaN(lowlength)
then upclose5[1] else
if x == 5
then lowlength
else upclose5[1];
plot u5 = upclose5;
u5.SetDefaultColor(Color.GREEN);
u5.SetPaintingStrategy(PaintingStrategy.DASHES);
u5.SetLineWeight(1);
defineGlobalColor("L", color.yellow);
input bubbles = yes;
input bubblemover = 3;
def b=bubblemover;
def b1=b+1;
addchartBubble(bubbles and isnan(close[b]) and !isnan(close[b1]), upclose1[b1], "Low 1: " + asdollars(upclose1[b1]), globalColor("L"));
addchartBubble(bubbles and isnan(close[b]) and !isnan(close[b1]), upclose2[b1], "Low 2: " + asdollars(upclose2[b1]), globalColor("L"));
addchartBubble(bubbles and isnan(close[b]) and !isnan(close[b1]), upclose3[b1], "Low 3: " + asdollars(upclose3[b1]), globalColor("L"));
addchartBubble(bubbles and isnan(close[b]) and !isnan(close[b1]), upclose4[b1], "Low 4: " + asdollars(upclose4[b1]), globalColor("L"));
addchartBubble(bubbles and isnan(close[b]) and !isnan(close[b1]), upclose5[b1], "Low 5: " + asdollars(upclose5[b1]), globalColor("L"));
#