Addchartbubble() Error

british43

Member
VIP
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);
 
@british43 Your Study is working exactly as you have it coded... If you want single bubbles you need to refine your conditional criteria... The 1 as the first parameter is the culprit... It should be replaced with the conditional criteria that fires when you want the bubble displayed... It's late so I can't advise beyond that at the moment...
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

@british43 See if this helps. The format of the Addchartbubble is different than the Addlabel..

AddChartBubble ( boolean time condition, double price location, Any text, CustomColor color, boolean up);
AddLabel ( boolean visible, Any text, CustomColor color);


Try this code in place of yours:
Code:
AddChartBubble(IsNaN(close), h, AsText(h), Color.RED);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
440 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top