Show stock price inside AddChartBubble

KevinSammy

Member
VIP
I am trying to display the lowest price on a candle as a bubble. I currently have it displayed above the candle as just the price, but the bubble would be ideal.

Here's the code for the price portion:

Code:
plot value3 =  if swing_lo and Lo < Hi and Lo > Lo[1] then pricelow else Double.NaN;
value3.SetPaintingStrategy(PaintingStrategy.VALUES_above);
value3.SetDefaultColor(Color.WHITE);

Can someone please take a look at the code for the bubble below and let me know how to do it? I've been trying for a while and am stuck.

Code:
AddChartBubble(swing_lo and Lo < Hi  and Lo > Lo[1], low, "HIGHER Low", Color.WHITE, yes);

Thank You!
 
Solution
Ok... So, it sounds like what you want is:

Code:
AddChartBubble(swing_lo and Lo < Hi and Lo > Lo[1], low, low, Color.WHITE, yes);

This code displays the actual price of low in place of the HIGHER Low text...

rad14733

Well-known member
VIP
Code:
AddChartBubble(swing_lo and Lo < Hi and Lo > Lo[1], low, "HIGHER Low", Color.WHITE, no);
The last parameter determines whether the label is displayed Above (yes) or Below (no)...
 

KevinSammy

Member
VIP
Thanks, but your code moves the bubble to the bottom of the candle....which is different than what I'm looking for - which is to display the price of the low of the candle in the bubble, instead of "HIGHER Low" :)
 

rad14733

Well-known member
VIP
Thanks, but your code moves the bubble to the bottom of the candle....which is different than what I'm looking for - which is to display the price of the low of the candle in the bubble, instead of "HIGHER Low" :)
Ahhh... Missed that part... We'd need to see the entire script to garner all of the logic rather than just the few lines you posted above...
 

KevinSammy

Member
VIP
Sure, that makes sense.

This is the line of code I want to add for the bubble to show the low price of the candle, instead of "HIGHER Low":
AddChartBubble(swing_lo and Lo < Hi and Lo > Lo[1], low, "HIGHER Low", Color.WHITE, yes);

adding others in case they can help:
@BenTen @horserider @markos


Here's the full code:

Code:
declare upper;
input showlabel=yes;
input showHiLoLines = yes; #plots res and support lines
input showbubble = yes; #plots hi/lo
input showZigZaglines = yes; #plots zigzaglines
input pricelow = low;

Def swinghigh = if high > high[1] and high > high[2] and high > high[-1] and high > high[-2] then 1 else 0;
Plot swing_hi = if swinghigh then high else double.nan;
swing_hi.setstyle(curve.points);
swing_hi.SetLineWeight(2);
swing_hi.SetDefaultColor(Color.red);
Def swinglow = if low < low[1] and low < low[2] and low < low[-1] and low < low[-2] then 1 else 0;
plot swing_lo = if swinglow then low else double.nan;
swing_lo.setstyle(curve.points);
swing_lo.SetLineWeight(2);
swing_lo.SetDefaultColor(Color.lime);

#plot swing high and swing low lines
def Hi = if !isNaN(swing_hi) then high else Hi[1];
def Lo = if !isNaN(swing_lo) then low else Lo[1];
plot R1 = if showHiLoLines then Hi else double.NaN;
plot S1 = if showHiLoLines then Lo else double.NaN;
R1.SetPaintingStrategy(PaintingStrategy.DASHES);
S1.setPaintingStrategy(paintingStrategy.DASHES);
R1.setDefaultColor(color.red);
s1.setDefaultColor(color.lime);

### plots zigzaglines
plot zigzag = if showZigZaglines and swinghigh then high else if showZigZaglines and swinglow then low else double.NaN;
zigzag.enableApproximation();
zigzag.SetPaintingStrategy(PaintingStrategy.line);
zigzag.setLineWeight(1);
zigzag.setDefaultColor(color.white);
addChartBubble(showbubble,swing_hi,if hi > lo and  hi > hi[1]  then "HH" else  "LH",color.white,yes);
addChartBubble(showbubble,swing_lo,if lo <hi  and lo < lo[1] then "LL" else "HL",color.white,yes);

plot value1 =  if swing_lo and Lo < Hi and Lo > Lo[1] then pricelow else Double.NaN;
value1.SetPaintingStrategy(PaintingStrategy.VALUES_below);
value1.SetDefaultColor(Color.WHITE);
 

rad14733

Well-known member
VIP
Ok... So, it sounds like what you want is:

Code:
AddChartBubble(swing_lo and Lo < Hi and Lo > Lo[1], low, low, Color.WHITE, yes);

This code displays the actual price of low in place of the HIGHER Low text...
 
Solution

KevinSammy

Member
VIP
Hello @rad14733

I am trying to code so that it auto draws a long horizontal line on the relevant candles for this script, but it draws only a small dash below the candle. Can you please review this code and let me know to get it to work properly?

Thank you again!!


plot line = if swing_lo and Lo < Hi and Lo > Lo[1] then low else Double.NaN;
line.SetDefaultColor(Color.white);
line.SetLineWeight(5);
line.SetPaintingStrategy(PaintingStrategy.Horizontal);
 

rad14733

Well-known member
VIP
Hello @rad14733

I am trying to code so that it auto draws a long horizontal line on the relevant candles for this script, but it draws only a small dash below the candle. Can you please review this code and let me know to get it to work properly?

Thank you again!!


plot line = if swing_lo and Lo < Hi and Lo > Lo[1] then low else Double.NaN;
line.SetDefaultColor(Color.white);
line.SetLineWeight(5);
line.SetPaintingStrategy(PaintingStrategy.Horizontal);
There is no know way to extend a line X number of bars forward via parameters... The only way I am aware of is the way it extends in the code listing you posted above... I was just searching for a way last night and even Pete Hahn isn't aware of a means of doing so... I can check around a bit more but, unfortunately, ThinkScript does have limitations that other platforms do not have...
 

OBW

Member
@KevinSammy

Ruby:
def low_level = if swinglow and Lo < high and Lo > Lo[1] then low else low_level[1];
plot line = low_level;
line.SetDefaultColor(Color.WHITE);
line.SetLineWeight(5);
line.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
 

rad14733

Well-known member
VIP
@KevinSammy

Ruby:
def low_level = if swinglow and Lo < high and Lo > Lo[1] then low else low_level[1];
plot line = low_level;
line.SetDefaultColor(Color.WHITE);
line.SetLineWeight(5);
line.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Was going to come back and suggest using a recursive variable last night but got busy working on an indicator and forgot... You beat me to it OBW... (y)
 

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.
Top