Hello, I am having some issues with addchartbubble(). The bubble is repeating itself more than once (addchartbubble(1,h,1,color.red); . I have been trying to fix but failed . The addchartbubble is at the bottom of the code. Any assistance would be greatly appreciate.
input PrevHigh = yes;
input PrevLow = yes;
input PrevOpen = yes;
input Prevclose = yes;
input PreviousMonthOnly = yes;
input LineWeight = 1;
def month = GetMonth();
input Today = AggregationPeriod.DAY;
def agg = Today;
plot quarterhigh = high(period = Today);
plot quarterlow = low(period = Today);
plot quarteropen = open(period = Today);
plot quarterclose = close(period = Today);
#high
plot h = if PreviousMonthOnly
then if Today
then high(period = agg)[1]
else Double.NaN
else high(period = agg)[1];
h.SetHiding(!PrevHigh);
h.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
h.SetLineWeight(LineWeight);
h.SetDefaultColor(Color.RED);
#low
plot l = if PreviousMonthOnly
then if Today
then low(period = agg)[1]
else Double.NaN
else low(period = agg)[1];
l.SetHiding(!PrevLow);
l.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
l.SetLineWeight(LineWeight);
l.SetDefaultColor(Color.GREEN);
#Open
plot O = if PreviousMonthOnly
then if Today
then open(period = agg)[1]
else Double.NaN
else open(period = agg)[1];
O.SetHiding(!PrevOpen);
O.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
O.SetLineWeight(LineWeight);
O.SetDefaultColor(Color.YELLOW);
#Close
plot cc = if PreviousMonthOnly
then if Today
then close(period = agg)[1]
else Double.NaN
else close(period = agg)[1];
cc.SetHiding(!Prevclose);
cc.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
cc.SetLineWeight(LineWeight);
cc.SetDefaultColor(Color.DARK_ORANGE);
def Data = if IsNaN(h)
then Data[1]
else h;
plot c = if IsNaN(h[-1]) then Data else Double.NaN;
c.SetStyle(Curve.FIRM);
c.SetLineWeight(1);
c.SetDefaultColor(Color.RED);
def Datal = if IsNaN(l)
then Datal[1]
else l;
plot cl = if IsNaN(l[-1]) then Datal else Double.NaN;
cl.SetStyle(Curve.FIRM);
cl.SetLineWeight(1);
cl.SetDefaultColor(Color.GREEN);
def Datao = if IsNaN(O)
then Datao[1]
else O;
plot co = if IsNaN(O[-1]) then Datao else Double.NaN;
co.SetStyle(Curve.FIRM);
co.SetLineWeight(1);
co.SetDefaultColor(Color.YELLOW);
def Datac = if IsNaN(cc)
then Datac[1]
else cc;
plot ccc = if IsNaN(cc[-1]) then Datac else Double.NaN;
ccc.SetStyle(Curve.FIRM);
ccc.SetLineWeight(1);
ccc.SetDefaultColor(Color.DARK_ORANGE);
####################
def avgRange = .05 * Average(quarterhigh - quarterlow, 20);
plot PatternPlotl = Between(quarterlow - low, -avgRange, avgRange);
PatternPlotl.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
PatternPlotl.SetDefaultColor(GetColor(0));
plot PatternPloth = Between(quarterhigh - high, -avgRange, avgRange);
PatternPloth.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
PatternPloth.SetDefaultColor(GetColor(0));
addchartbubble(1,h,1,color.red);
input PrevHigh = yes;
input PrevLow = yes;
input PrevOpen = yes;
input Prevclose = yes;
input PreviousMonthOnly = yes;
input LineWeight = 1;
def month = GetMonth();
input Today = AggregationPeriod.DAY;
def agg = Today;
plot quarterhigh = high(period = Today);
plot quarterlow = low(period = Today);
plot quarteropen = open(period = Today);
plot quarterclose = close(period = Today);
#high
plot h = if PreviousMonthOnly
then if Today
then high(period = agg)[1]
else Double.NaN
else high(period = agg)[1];
h.SetHiding(!PrevHigh);
h.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
h.SetLineWeight(LineWeight);
h.SetDefaultColor(Color.RED);
#low
plot l = if PreviousMonthOnly
then if Today
then low(period = agg)[1]
else Double.NaN
else low(period = agg)[1];
l.SetHiding(!PrevLow);
l.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
l.SetLineWeight(LineWeight);
l.SetDefaultColor(Color.GREEN);
#Open
plot O = if PreviousMonthOnly
then if Today
then open(period = agg)[1]
else Double.NaN
else open(period = agg)[1];
O.SetHiding(!PrevOpen);
O.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
O.SetLineWeight(LineWeight);
O.SetDefaultColor(Color.YELLOW);
#Close
plot cc = if PreviousMonthOnly
then if Today
then close(period = agg)[1]
else Double.NaN
else close(period = agg)[1];
cc.SetHiding(!Prevclose);
cc.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
cc.SetLineWeight(LineWeight);
cc.SetDefaultColor(Color.DARK_ORANGE);
def Data = if IsNaN(h)
then Data[1]
else h;
plot c = if IsNaN(h[-1]) then Data else Double.NaN;
c.SetStyle(Curve.FIRM);
c.SetLineWeight(1);
c.SetDefaultColor(Color.RED);
def Datal = if IsNaN(l)
then Datal[1]
else l;
plot cl = if IsNaN(l[-1]) then Datal else Double.NaN;
cl.SetStyle(Curve.FIRM);
cl.SetLineWeight(1);
cl.SetDefaultColor(Color.GREEN);
def Datao = if IsNaN(O)
then Datao[1]
else O;
plot co = if IsNaN(O[-1]) then Datao else Double.NaN;
co.SetStyle(Curve.FIRM);
co.SetLineWeight(1);
co.SetDefaultColor(Color.YELLOW);
def Datac = if IsNaN(cc)
then Datac[1]
else cc;
plot ccc = if IsNaN(cc[-1]) then Datac else Double.NaN;
ccc.SetStyle(Curve.FIRM);
ccc.SetLineWeight(1);
ccc.SetDefaultColor(Color.DARK_ORANGE);
####################
def avgRange = .05 * Average(quarterhigh - quarterlow, 20);
plot PatternPlotl = Between(quarterlow - low, -avgRange, avgRange);
PatternPlotl.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
PatternPlotl.SetDefaultColor(GetColor(0));
plot PatternPloth = Between(quarterhigh - high, -avgRange, avgRange);
PatternPloth.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
PatternPloth.SetDefaultColor(GetColor(0));
addchartbubble(1,h,1,color.red);