How to convert bubbles to labels in the code

hockeycoachdoug

Member
2019 Donor
VIP
I have a purchased indicator that I like using, but when it labels signal lines on the chart it produces a bubble showing the value, price, etc. These bubbles cover up the bars on the chart. Is there a way to just show the value on the chart (like Tradestation does) without the bubble. I have seen posts about making the bubble translucent, but it still covers up the bars on the cart. Can you just call for labels to show on the chart with the values shown rather then a bubble. I am including a small snippet where the codes calls for a bubble to plot. Can I just change to say something like AddCartLabel instead of AddChartBubble likes it calls for in the code?

Here is snippet- AddChartBubble(DisplayExit and isNaN(VRewardRisk) == no and displayBubble, DisplayLoc, round(VRewardRisk, 1) + "X", if VRewardRisk> 0 then GlobalColor("WinTradeColor") else GlobalColor("LoseTradeColor"));

Here is what it looks like on a chart in Tradestation- Tradestation version

Here is what it looks like on a chart in TOS- TOS version

I can turn the bubbles off in the TOS version under settings, but then I can't see the values that used to be shown in the bubbles. Can I just show them as labels somehow?
 

halcyonguy

Active member
VIP
i copied your bubble code and made a test study, so you could see some possibilities.
i added test data to trigger your variables and added several functions to display data.

...vertical line. it can display numbers and text.
...values above/below. this is a boolean parameter. it is above or below a candle. you can't specify a price to locate it.
...label. for a label to always display data, it requires data to exist for all bars.

Ruby:
# testvalueabove


# add test code ================
def na = double.nan;
def displayExit = 1;
def VRewardRisk = 7;
def DisplayLoc = low;

input start = 1030;
def displayBubble = if secondsfromTime(start) == 0 then 1 else 0;
#input displayBubble = yes;

DefineGlobalColor("WinTradeColor", color.green);
DefineGlobalColor("LoseTradeColor", color.red);
# ==============================

#Here is snippet-
AddChartBubble(DisplayExit and isNaN(VRewardRisk) == no and displayBubble, DisplayLoc, round(VRewardRisk, 1) + "X", if VRewardRisk> 0 then GlobalColor("WinTradeColor") else GlobalColor("LoseTradeColor"), no);

# vertline
addverticalline(DisplayExit and isNaN(VRewardRisk) == no and displayBubble, round(VRewardRisk, 1) + "X", if VRewardRisk> 0 then GlobalColor("WinTradeColor") else GlobalColor("LoseTradeColor"), curve.SHORT_DASH);

# values_above ,  puts a number above a candle
plot x = if (DisplayExit and isNaN(VRewardRisk) == no and displayBubble) then DisplayLoc else na;
x.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
x.SetDefaultColor(Color.white);
x.hidebubble();

# label ver
# to use a label, will have to keep the last desired value, so it can be shown on all following bars
def t = (DisplayExit and isNaN(VRewardRisk) == no and displayBubble);
def VRewardRisk2 = if t then round(VRewardRisk, 1) else VRewardRisk2[1];
addlabel(1, VRewardRisk2 + "X", if VRewardRisk> 0 then GlobalColor("WinTradeColor") else GlobalColor("LoseTradeColor"));


# RGB  hex  color picker
# https://www.w3schools.com/colors/colors_picker.asp

# RGB color
input red_start_num = 153;
def rd = red_start_num;
input green_start_num = 255;
def gn = green_start_num;
input blue_start_num = 153;
def bl = blue_start_num;

DefineGlobalColor("color1", CreateColor(rd,gn,bl));
addchartbubble(displayBubble, high * 1.005, "xxx", GlobalColor("color1"), yes);
#

jdnwDX9.jpg



i was going to say , you could define a RGB color, that is very light in color, for the bubbles. but this isn't transparent, just a light shade of a color. i left the code in my example.
https://www.w3schools.com/colors/colors_picker.asp


here is a link that lists many custom RGB colors
Color Labels with RGBs for ThinkorSwim
https://usethinkscript.com/threads/color-labels-with-rgbs-for-thinkorswim.214/


AddChartBubble ( boolean time condition, double price location, Any text, CustomColor color, boolean up);
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/AddChartBubble

AddLabel ( boolean visible, Any text, CustomColor color);
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/AddLabel

AddVerticalLine ( boolean visible, Any text, CustomColor color, int stroke);
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/AddVerticalLine
 
Top