AddChartBubble

Kden

New member
Please HELP,
Please show me how to get AddChartBubble to work on mobile device. TD Ameritrade wont tell me since they dont like me to mess with their platform settings. It works fine on PC

Thank you in advance,
Kden
 
Solution
I'm trying to add 46 horizontal lines. I am able to add the 'input' lines to the code with no problems detected. When I try to add the Plots I get an "Invalid statement" on the 10th plot attempt 'plot 20 = price10'. I ended up having to break this up into 5 separate studies of 10 numbers each to get it to 'work'.

Secondarily, I'd like to add an alert to show when the close crosses (up or down) any one of these points.
I tried adding the following lines to the Auto Horizontal Lines code

def price = close;
def xprice1 = price crossingDirection.ANY price1;

however I get an "Invalid statement on the 2nd line.

What am I doing wrong on this coding? I put the # in front of the input lines to clean up the input screen for the...

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

AddChartBubble((barnumber and D1), if isUp then low else high, if showarrows and signal < 0 and signal[1] >= 0 then "Sell $" + high else "", if Colorbars == 3 then Color.Plum else Color.Uptick, yes);
^^^^^^
( I like it blank for color.plum)
is there a way to tell addchartbubble to add a blank bubble instead of color?

Thank you,
Kden
 
AddChartBubble((barnumber and D1), if isUp then low else high, if showarrows and signal < 0 and signal[1] >= 0 then "Sell $" + high else "", if Colorbars == 3 then Color.Plum else Color.Uptick, yes);
^^^^^^
( I like it blank for color.plum)
is there a way to tell addchartbubble to add a blank bubble instead of color?

Thank you,
Kden

Without providing all of the code, I could not test the following, but it may work as you want:

Ruby:
AddChartBubble((barnumber and D1), if isUp then low else high, if colorbars == 3 then "" else if !colorbars == 3 and showarrows and signal < 0 and signal[1] >= 0 then "Sell $" + high else "", if Colorbars == 3 then Color.Plum else Color.Uptick, yes);
 
Can someone help create chart bubble for this indicator that plots horizontal lines?

# Auto Horizontal Lines

input price1 = 130;

plot l1 = price1;

Try this

Ruby:
# Auto Horizontal Lines

input price1 = 130;

plot l1 = price1;

input bubblemover = 3;
def b  = bubblemover;
def b1 = b + 1;
AddChartBubble(!IsNaN(close[b1]) and IsNaN(close[b]), l1, l1, Color.WHITE);
 
Last edited by a moderator:
What I was trying to do was create a chart bubble that I could add text to. I'm charting lines from spot gamma for support and resistance and wanted to use a script to draw lines that also included chart bubble "wall call" and "put wall" and so on. Here is what I got but it's not working:

# Auto Horizontal Lines

input price1 = 130;

plot l1 = price1;

AddChartBubble (price1, 130, "test", color.red, no);

I appreciate your help :)
 
What I was trying to do was create a chart bubble that I could add text to. I'm charting lines from spot gamma for support and resistance and wanted to use a script to draw lines that also included chart bubble "wall call" and "put wall" and so on. Here is what I got but it's not working:

# Auto Horizontal Lines

input price1 = 130;

plot l1 = price1;

AddChartBubble (price1, 130, "test", color.red, no);

I appreciate your help :)

What I posted above should work with the addition of the text you wanted. You can move the bubble sideways at the input bubblemover. Also, you can add a line to the text below by replacing "test" with "text\n"+l1 and the bubble will display as

test
130


Capture.jpg
Ruby:
# Auto Horizontal Lines

input price1 = 130;

plot l1 = price1;

input bubblemover = 3;
def b  = bubblemover;
def b1 = b + 1;
AddChartBubble(!IsNaN(close[b1]) and IsNaN(close[b]), l1, "test" + l1, Color.WHITE, no);
 
What I posted above should work with the addition of the text you wanted. You can move the bubble sideways at the input bubblemover. Also, you can add a line to the text below by replacing "test" with "text\n"+l1 and the bubble will display as

test
130
I have one more piece I need help with. I want multiple lines. What do I do to add more lines? I'm guessing it is part of the input bubblemover part, right? Is there a limit to how many lines I can add?

# Auto Horizontal Lines

input price1 = 130;
input price2 = 131;

plot l1 = price1;
plot l2 = price1;

input bubblemover = 3;
def b = bubblemover;
def b1 = b + 1;

input bubblemover2 = 3;
def b2 = bubblemover;
def b2 = b + 1;

AddChartBubble(!IsNaN(close[b1]) and IsNaN(close), l1, "Call Wall " + l1, Color.LIGHT_RED, no);
AddChartBubble(!IsNaN(close[b2]) and IsNaN(close), l2, "Put Wall " + l2, Color.GREEN, no);
 
I have one more piece I need help with. I want multiple lines. What do I do to add more lines? I'm guessing it is part of the input bubblemover part, right? Is there a limit to how many lines I can add?

# Auto Horizontal Lines

input price1 = 130;
input price2 = 131;

plot l1 = price1;
plot l2 = price1;

input bubblemover = 3;
def b = bubblemover;
def b1 = b + 1;

input bubblemover2 = 3;
def b2 = bubblemover;
def b2 = b + 1;

AddChartBubble(!IsNaN(close[b1]) and IsNaN(close), l1, "Call Wall " + l1, Color.LIGHT_RED, no);
AddChartBubble(!IsNaN(close[b2]) and IsNaN(close), l2, "Put Wall " + l2, Color.GREEN, no);

Yes, you can add as many lines as needed. Your code had both l1 and l2 equal to price1, causing you not being able to see the additional line.
Also, you do not need the bubblemover2 code. See below for modifications that should help.

Ruby:
# Auto Horizontal Lines

input price1 = 130;
input price2 = 131;

plot l1 = price1;
plot l2 = price2;

input bubblemover = 3;
def b = bubblemover;
def b1 = b + 1;


AddChartBubble(!IsNaN(close[b1]) and IsNaN(close), l1, "Call Wall " + l1, Color.LIGHT_RED, no);
AddChartBubble(!IsNaN(close[b1]) and IsNaN(close), l2, "Put Wall " + l2, Color.GREEN, no);
 
Yes, you can add as many lines as needed. Your code had both l1 and l2 equal to price1, causing you not being able to see the additional line.
Also, you do not need the bubblemover2 code. See below for modifications that should help.
I'm trying to add 46 horizontal lines. I am able to add the 'input' lines to the code with no problems detected. When I try to add the Plots I get an "Invalid statement" on the 10th plot attempt 'plot 20 = price10'. I ended up having to break this up into 5 separate studies of 10 numbers each to get it to 'work'.

Secondarily, I'd like to add an alert to show when the close crosses (up or down) any one of these points.
I tried adding the following lines to the Auto Horizontal Lines code

def price = close;
def xprice1 = price crossingDirection.ANY price1;

however I get an "Invalid statement on the 2nd line.

What am I doing wrong on this coding? I put the # in front of the input lines to clean up the input screen for the separate studies I had to create. If I can reduce the 5 studies into one study that would be the desired outcome. Horizontal lines plot, and an alert when the close crosses any one of them.

The numbers represent Gerald Appel's "Magic Numbers" as written in his Systems and Forecasts newsletter. His were between 8 and 154. I extrapolated the other numbers above and below his. His are based on observations, mine are based on math and round numbers for the most part.

Any help is greatly appreciated.

Code:
# Auto Horizontal Lines

input price1 =  0.8;
input price2 =  1;
input price3 =  1.2;
input price4 =  1.5;
input price5 =  1.75;
input price6 =  2.25;
input price7 =  2.75;
input price8 =  3.5;
input price9 =  4.25;
input price10 =  5.25;
#input price11 =  6.5;
#input price12 =  8;
#input price13 =  10;
#input price14 =  12.25;
#input price15 =  14;
#input price16 =  16;
#input price17 =  20.25;
#input price18 =  24.5;
#input price19 =  28.75;
#input price20 =  33;
#input price21 =  38.5;
#input price22 =  44;
#input price23 =  49.5;
#input price24 =  55;
#input price25 =  65;
#input price26 =  77;
#input price27 =  88;
#input price28 =  99;
#input price29 =  110;
#input price30 =  130;
#input price31 =  154;
#input price32 =  183;
#input price33 =  217;
#input price34 =  255;
#input price35 =  300;
#input price36 =  350;
#input price37 =  420;
#input price38 =  500;
#input price39 =  600;
#input price40 =  725;
#input price41 =  875;
#input price42 =  1050;
#input price43 =  1250;
#input price44 =  1500;
#input price45 =  1800;
#input price46 =  2170;

plot l1 = price1;
plot l2 = price2;
plot l3 = price3;
plot l4 = price4;
plot l5 = price5;
plot l6 = price6;
plot l7 = price7;
plot l8 = price8;
plot l9 = price9;
plot 20 = price10[/CODE;]
 
I'm trying to add 46 horizontal lines. I am able to add the 'input' lines to the code with no problems detected. When I try to add the Plots I get an "Invalid statement" on the 10th plot attempt 'plot 20 = price10'. I ended up having to break this up into 5 separate studies of 10 numbers each to get it to 'work'.

Secondarily, I'd like to add an alert to show when the close crosses (up or down) any one of these points.
I tried adding the following lines to the Auto Horizontal Lines code

def price = close;
def xprice1 = price crossingDirection.ANY price1;

however I get an "Invalid statement on the 2nd line.

What am I doing wrong on this coding? I put the # in front of the input lines to clean up the input screen for the separate studies I had to create. If I can reduce the 5 studies into one study that would be the desired outcome. Horizontal lines plot, and an alert when the close crosses any one of them.

The numbers represent Gerald Appel's "Magic Numbers" as written in his Systems and Forecasts newsletter. His were between 8 and 154. I extrapolated the other numbers above and below his. His are based on observations, mine are based on math and round numbers for the most part.

Any help is greatly appreciated.

Code:
# Auto Horizontal Lines

input price1 =  0.8;
input price2 =  1;
input price3 =  1.2;
input price4 =  1.5;
input price5 =  1.75;
input price6 =  2.25;
input price7 =  2.75;
input price8 =  3.5;
input price9 =  4.25;
input price10 =  5.25;
#input price11 =  6.5;
#input price12 =  8;
#input price13 =  10;
#input price14 =  12.25;
#input price15 =  14;
#input price16 =  16;
#input price17 =  20.25;
#input price18 =  24.5;
#input price19 =  28.75;
#input price20 =  33;
#input price21 =  38.5;
#input price22 =  44;
#input price23 =  49.5;
#input price24 =  55;
#input price25 =  65;
#input price26 =  77;
#input price27 =  88;
#input price28 =  99;
#input price29 =  110;
#input price30 =  130;
#input price31 =  154;
#input price32 =  183;
#input price33 =  217;
#input price34 =  255;
#input price35 =  300;
#input price36 =  350;
#input price37 =  420;
#input price38 =  500;
#input price39 =  600;
#input price40 =  725;
#input price41 =  875;
#input price42 =  1050;
#input price43 =  1250;
#input price44 =  1500;
#input price45 =  1800;
#input price46 =  2170;

plot l1 = price1;
plot l2 = price2;
plot l3 = price3;
plot l4 = price4;
plot l5 = price5;
plot l6 = price6;
plot l7 = price7;
plot l8 = price8;
plot l9 = price9;
plot 20 = price10[/CODE;]

If you have preset numbers, then just a plot is needed, without the input statement.

I have made the adjustments and added alerts that should work.

Ruby:
plot price1 =  0.8;
plot price2 =  1;
plot price3 =  1.2;
plot price4 =  1.5;
plot price5 =  1.75;
plot price6 =  2.25;
plot price7 =  2.75;
plot price8 =  3.5;
plot price9 =  4.25;
plot price10 =  5.25;
plot price11 =  6.5;
plot price12 =  8;
plot price13 =  10;
plot price14 =  12.25;
plot price15 =  14;
plot price16 =  16;
plot price17 =  20.25;
plot price18 =  24.5;
plot price19 =  28.75;
plot price20 =  33;
plot price21 =  38.5;
plot price22 =  44;
plot price23 =  49.5;
plot price24 =  55;
plot price25 =  65;
plot price26 =  77;
plot price27 =  88;
plot price28 =  99;
plot price29 =  110;
plot price30 =  130;
plot price31 =  154;
plot price32 =  183;
plot price33 =  217;
plot price34 =  255;
plot price35 =  300;
plot price36 =  350;
plot price37 =  420;
plot price38 =  500;
plot price39 =  600;
plot price40 =  725;
plot price41 =  875;
plot price42 =  1050;
plot price43 =  1250;
plot price44 =  1500;
plot price45 =  1800;
plot price46 =  2170;

input alerts = yes;

Alert(alerts and close crosses price1, "Cross " + price1, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price2, "Cross " + price2, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price3, "Cross " + price3, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price4, "Cross " + price4, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price5, "Cross " + price5, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price6, "Cross " + price6, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price7, "Cross " + price7, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price8, "Cross " + price8, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price9, "Cross " + price9, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price10, "Cross " + price10, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price11, "Cross " + price11, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price12, "Cross " + price12, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price13, "Cross " + price13, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price14, "Cross " + price14, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price15, "Cross " + price15, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price16, "Cross " + price16, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price17, "Cross " + price17, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price18, "Cross " + price18, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price19, "Cross " + price19, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price20, "Cross " + price20, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price21, "Cross " + price21, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price22, "Cross " + price22, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price23, "Cross " + price23, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price24, "Cross " + price24, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price25, "Cross " + price25, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price26, "Cross " + price26, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price27, "Cross " + price27, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price28, "Cross " + price28, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price29, "Cross " + price29, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price30, "Cross " + price30, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price31, "Cross " + price31, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price32, "Cross " + price32, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price33, "Cross " + price33, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price34, "Cross " + price34, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price35, "Cross " + price35, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price36, "Cross " + price36, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price37, "Cross " + price37, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price38, "Cross " + price38, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price39, "Cross " + price39, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price40, "Cross " + price40, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price41, "Cross " + price41, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price42, "Cross " + price42, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price43, "Cross " + price43, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price44, "Cross " + price44, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price45, "Cross " + price45, Alert.BAR, Sound.Ding);
Alert(alerts and close crosses price46, "Cross " + price46, Alert.BAR, Sound.Ding);
 
Solution
If you have preset numbers, then just a plot is needed, without the input statement.

I have made the adjustments and added alerts that should work.
This does work as expected. Thank you so much.

I'm trying to learn coming from a non programming background. The inputs was the issue on the plots? I'm trying to learn what was "Invalid" about the coding. I do appreciate your help.

I see, and get, the logic on the alerts you added. Can a Label to show on the chart header be added if the alert has been triggered? The Alert box is good but fleeting. I'm guessing a long if-then-else would be required for the label?

AddLabel(1, “magic nbr cross “ + If close crosses price1, then price1 else
If close crosses price2, then price2 else
If close crosses price3, then price3 else
If close crosses price4, then price4 else
If close crosses price5, then price5 else
color.dark_green);

or something like that?

Thank you again.
 
This does work as expected. Thank you so much.

I'm trying to learn coming from a non programming background. The inputs was the issue on the plots? I'm trying to learn what was "Invalid" about the coding. I do appreciate your help.

I see, and get, the logic on the alerts you added. Can a Label to show on the chart header be added if the alert has been triggered? The Alert box is good but fleeting. I'm guessing a long if-then-else would be required for the label?

AddLabel(1, “magic nbr cross “ + If close crosses price1, then price1 else
If close crosses price2, then price2 else
If close crosses price3, then price3 else
If close crosses price4, then price4 else
If close crosses price5, then price5 else
color.dark_green);

or something like that?

Thank you again.

Your code had a syntax error at plot 20 = price10;. You cannot start a plot name with a number. You could do this plot "20" = price10; As all of the other plot names began with the letter 'l', then I asume you just made a typo from l9 to 20.

Yes, you could try a long if/else if/else statement within a label. This uses a 'within x bars' to keep the label displayed so you can see it for awhile.

Screenshot-2022-11-17-133329.png
Ruby:
input x     = 3;
plot price1 = 14.68;
plot price2 = 14.73;
addlabel(1,
if close crosses price1 within x bars then "Cross " + price1 else
if close crosses price2 within x bars then "Cross " + price2 else
"",
color.yellow);
 
Your code had a syntax error at plot 20 = price10;. You cannot start a plot name with a number. You could do this plot "20" = price10; As all of the other plot names began with the letter 'l', then I asume you just made a typo from l9 to 20.

Yes, you could try a long if/else if/else statement within a label. This uses a 'within x bars' to keep the label displayed so you can see it for awhile.
Thank you for the help, and the explanation on the error, and the Label code. I would have been back on the label code looking for the else "" I am positive.

Thank you again for all the help. I really appreciate it.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
333 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