move bubbles more off to the right

khpro59

Active member
VIP
How do I make the bubbles more off to the right in the B3_HILO_V3 study. Essentially I feel the bubbles are to on-top of the price action and difficult to read, id like to retain the bubbles but push them to the right a bit? Thanks for your help as always, you are a god around here.

Code:
# Simply plots a line at the latest printing of a high or low for each day (or agg of your choosing).
# Note that your aggs chosen in this study must be a longer time frame than your chart's agg for this to study to plot.
#
# Version 2 adds the 50% of 1d and 2d ranges.
# Version 3 adds Closeweighting and made it optional.
# Version 3.1 cleans the code up and straightens out features (housekeeping).
##
DECLARE UPPER;
INPUT AGG = AGgregationPeriod.DAY;
INPUT BUBBLES = NO;
INPUT LABELS = NO;
INPUT CLOSEWEIGHTTODAY = NO;
INPUT CLOSEWEIGHTYEST = yes;
INPUT CLOSEWEIGHTTWODAY = yes;
PLOT HI = HIGH(PERIOD = AGG);
PLOT LO = LOW(PERIOD = AGG);
PLOT YHI = HIGH(PERIOD = AGG)[1];
PLOT YLO = LOW(PERIOD = AGG)[1];
PLOT FIFTYPCT = if cloSEWEIGHTTODAY then (hi + lo + close(period = agg)) / 3 else (HI + LO) / 2;
PLOT YESTERDAYFTYPCT = if cloSEWEIGHTYEST then (yhi + ylo + close(period = agg)[1]) / 3 else (YHI + YLO) / 2;
DEF WHICHHI = IF YHI > YHI[1] THEN YHI ELSE YHI[1];
DEF WHICHLO = IF YLO < YLO[1] THEN YLO ELSE YLO[1];
DEF TODAY = if (GetDay() == GetLastDay()) or (GetlastDay() - 1 == getday()) then yes else no;
DEF BUBBLESPOT = if IsNaN(open[-1]) && !IsNaN(open) then (BarNumber() - 1) else DOUBLE.NAN;
PLOT FIFTYPCTTWODAY = if ClOSEWEIGHTTWODAY then (WHICHHI + WHICHLO + close(period = AGG)[1]) / 3 else (WHICHHI + WHICHLO) / 2;
HI.SETLINEWeight(2);
LO.SETLINEWeight(2);
HI.SETDefaultColor(CREATECOlor(166,130,166));
LO.SETDefaultColor(CREATECOlor(166,130,166));
YLO.SETDefaultColor(CREATECOlor(146,120,146));
YHI.SETDefaultColor(CREATECOlor(146,120,146));
FIFTYPCT.setDefaultColor(Color.GRAY);
FIFTYPCT.setpaintingStrategy(paintingStrategy.DASHES);
YESTERDAYFTYPCT.setDefaultColor(Color.Dark_GRAY);
YESTERDAYFTYPCT.setpaintingStrategy(paintingStrategy.SQUARES);
FIFTYPCTTWODAY.setDefaultColor(Color.GRAY);
FIFTYPCTTWODAY.setpaintingStrategy(paintingStrategy.TRIANGLES);
ADDLABEL(LABELS, "HI/50/LO=" + HI + "/ " + FIFTYPCT +"/ " + LO, CREATECOlor(166,130,166));
ADDLABEL(LABELS, "2D 50%=" + FIFTYPCTTWODAY, COLOR.GRAY);
ADDLABEL(LABELS, "YEST=" + YHI + "/ " + YESTERDAYFTYPCT + "/ " + YLO, CREATECOlor(146,120,146));

ADDCHARTBUBBLE(BUBBLES AND TODAY AND BUBBLESPOT, HI, "HI",CREATECOlor(166,130,166), YES);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND BUBBLESPOT, LO, "LO",CREATECOlor(166,130,166), NO);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND BUBBLESPOT, YHI, "YEST HI",CREATECOlor(146,120,146), if close > YHI then NO else YES);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND BUBBLESPOT, YLO, "YEST LO",CREATECOlor(146,120,146), if close > YLO then NO else YES);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND BUBBLESPOT, FIFTYPCT, "TODAY 50%", COLOR.GRAY, IF CLOSE > FIFTYPCT THEN NO ELSE YES);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND BUBBLESPOT, YESTERDAYFTYPCT, "YEST 50%", COLOR.GRAY, IF CLOSE > YESTERDAYFTYPCT THEN NO ELSE YES);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND BUBBLESPOT, FIFTYPCTTWODAY, "2D 50%", COLOR.GRAY, IF CLOSE > FIFTYPCTTWODAY THEN NO ELSE YES);
 
Last edited by a moderator:
Solution
How do I make the bubbles more off to the right in the B3_HILO_V3 study. Essentially I feel the bubbles are to on-top of the price action and difficult to read, id like to retain the bubbles but push them to the right a bit? Thanks for your help as always, you are a god around here.

i didn't load this , but i assume you want bubbles after the last bar.

shapes can be placed after the last bar,
by creating a true/false formula, that checks,
if some previous bar had valid price data, and the bar after that one does not have valid price data.

this is true when on the bar that is 4 bars after the last bar
def x = !isNaN(close[4+1]) and isNaN(close[4]);

have to remember to read a previous valid bar for a price value, because...
How do I make the bubbles more off to the right in the B3_HILO_V3 study. Essentially I feel the bubbles are to on-top of the price action and difficult to read, id like to retain the bubbles but push them to the right a bit? Thanks for your help as always, you are a god around here.

i didn't load this , but i assume you want bubbles after the last bar.

shapes can be placed after the last bar,
by creating a true/false formula, that checks,
if some previous bar had valid price data, and the bar after that one does not have valid price data.

this is true when on the bar that is 4 bars after the last bar
def x = !isNaN(close[4+1]) and isNaN(close[4]);

have to remember to read a previous valid bar for a price value, because there are no prices after the last bar.


here are a couple ways to place a bubble after the last bar
https://usethinkscript.com/threads/bubblemover-code-snippet-for-thinkorswim.9392/#post-85145

https://usethinkscript.com/threads/display-bubble-on-the-right-edge.3037/#post-66620
 
Last edited:
Solution
i didn't load this , but i assume you want bubbles after the last bar.

shapes can be placed after the last bar,
by creating a true/false formula, that checks,
if some previous bar had valid price data, and the bar after that one does not have valid price data.

this is true when on the bar that is 4 bars after the last bar
def x = !isNaN(close[4+1]) and isNaN(close[4]);

have to remember to read a previous valid bar for a price value, because there are no prices after the last bar.


here are a couple ways to place a bubble after the last bar
https://usethinkscript.com/threads/bubblemover-code-snippet-for-thinkorswim.9392/#post-85145

https://usethinkscript.com/threads/display-bubble-on-the-right-edge.3037/#post-66620
Appreciate the help and relocation of my question. But I have the bubbles I just want to move them to the right so they arent on top of current candle. Does that make sense?

 
Appreciate the help and relocation of my question. But I have the bubbles I just want to move them to the right so they arent on top of current candle. Does that make sense?

merryday tends to move posts around, with others similar to it.

'after the last bar' , tends to mean,
moving shapes to the right. what i posted will help you do what you want to do.
 
well perfect, I apologize, I thought you misunderstood. I will take a look at your links.

Thank you

you're welcome. take a look , copy 1 or both codes and try them.

thanks for questioning my post. i looked it over and found my code ( the 2nd link in post#2 ) was off by 1 bar.
i updated the code in my other post and and simplified it. i added a big bubble with words describing what it is doing.
and i added an image of it, so people will know right away what the code will do.
 
Last edited:
Hmm well I appreciate the help, guess im not much of a coder... Usually I can figure it out, but this has me stumped. I found the second post you sent more helpful, with the following line of code:

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

DefineGlobalColor("D”, CreateColor(133, 163, 104));
AddChartBubble(IsNaN(RRBub[b1]) and !IsNaN(RRBub), RR, "RR", GlobalColor("D"));



I am still having issues on where to post that line of code. I realize the last sentence is two seperate codes, so it wasnt that, that tripped me up. I placed it at the beginning of my code just like I saw others did in that thread. But no dice. I played around with the addchartbubble code, I just cant figure out where to put it. Can you just let me know after what would I add something like this? If it helps to refer to the picture above - so that you know what I am after, I just think the several instances of "bubblespot" may be throwing it off? There should be 7 bubbles in all, and all shifted to the right by 11 spaces (I say 11 because I saw a user had 11 inputted in his/hers and it looked about right. Thanks again for all your help.


Code:
DECLARE UPPER;
input bubblemover = 11;
def n  = bubblemover;
def n1 = n + 1;
INPUT AGG = AGgregationPeriod.DAY;
INPUT BUBBLES = NO;
INPUT LABELS = NO;
INPUT CLOSEWEIGHTTODAY = NO;
INPUT CLOSEWEIGHTYEST = yes;
INPUT CLOSEWEIGHTTWODAY = yes;
PLOT HI = HIGH(PERIOD = AGG);
PLOT LO = LOW(PERIOD = AGG);
PLOT YHI = HIGH(PERIOD = AGG)[1];
PLOT YLO = LOW(PERIOD = AGG)[1];
PLOT FIFTYPCT = if cloSEWEIGHTTODAY then (hi + lo + close(period = agg)) / 3 else (HI + LO) / 2;
PLOT YESTERDAYFTYPCT = if cloSEWEIGHTYEST then (yhi + ylo + close(period = agg)[1]) / 3 else (YHI + YLO) / 2;
DEF WHICHHI = IF YHI > YHI[1] THEN YHI ELSE YHI[1];
DEF WHICHLO = IF YLO < YLO[1] THEN YLO ELSE YLO[1];
DEF TODAY = if (GetDay() == GetLastDay()) or (GetlastDay() - 1 == getday()) then yes else no;
DEF BUBBLESPOT = if IsNaN(open[-1]) && !IsNaN(open) then (BarNumber() - 1) else DOUBLE.NAN;
PLOT FIFTYPCTTWODAY = if ClOSEWEIGHTTWODAY then (WHICHHI + WHICHLO + close(period = AGG)[1]) / 3 else (WHICHHI + WHICHLO) / 2;
HI.SETLINEWeight(2);
LO.SETLINEWeight(2);
HI.SETDefaultColor(CREATECOlor(166,130,166));
LO.SETDefaultColor(CREATECOlor(166,130,166));
YLO.SETDefaultColor(CREATECOlor(146,120,146));
YHI.SETDefaultColor(CREATECOlor(146,120,146));
FIFTYPCT.setDefaultColor(Color.GRAY);
FIFTYPCT.setpaintingStrategy(paintingStrategy.DASHES);
YESTERDAYFTYPCT.setDefaultColor(Color.Dark_GRAY);
YESTERDAYFTYPCT.setpaintingStrategy(paintingStrategy.SQUARES);
FIFTYPCTTWODAY.setDefaultColor(Color.GRAY);
FIFTYPCTTWODAY.setpaintingStrategy(paintingStrategy.TRIANGLES);
ADDLABEL(LABELS, "HI/50/LO=" + HI + "/ " + FIFTYPCT +"/ " + LO, CREATECOlor(166,130,166));
ADDLABEL(LABELS, "2D 50%=" + FIFTYPCTTWODAY, COLOR.GRAY);
ADDLABEL(LABELS, "YEST=" + YHI + "/ " + YESTERDAYFTYPCT + "/ " + YLO, CREATECOlor(146,120,146));

ADDCHARTBUBBLE(BUBBLES AND TODAY AND BUBBLESPOT, HI, "HI",CREATECOlor(166,130,166), YES);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND BUBBLESPOT, LO, "LO",CREATECOlor(166,130,166), NO);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND BUBBLESPOT, YHI, "YEST HI",CREATECOlor(146,120,146), if close > YHI then NO else YES);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND BUBBLESPOT, YLO, "YEST LO",CREATECOlor(146,120,146), if close > YLO then NO else YES);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND BUBBLESPOT, FIFTYPCT, "TODAY 50%", COLOR.GRAY, IF CLOSE > FIFTYPCT THEN NO ELSE YES);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND BUBBLESPOT, YESTERDAYFTYPCT, "YEST 50%", COLOR.GRAY, IF CLOSE > YESTERDAYFTYPCT THEN NO ELSE YES);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND BUBBLESPOT, FIFTYPCTTWODAY, "2D 50%", COLOR.GRAY, IF CLOSE > FIFTYPCTTWODAY THEN NO ELSE YES);
 
Bubbles to the far right

Code:
# Simply plots a line at the latest printing of a high or low for each day (or agg of your choosing).
# Note that your aggs chosen in this study must be a longer time frame than your chart's agg for this to study to plot.
#
# Version 2 adds the 50% of 1d and 2d ranges.
# Version 3 adds Closeweighting and made it optional.
# Version 3.1 cleans the code up and straightens out features (housekeeping).
##
DECLARE UPPER;
INPUT AGG = AGgregationPeriod.DAY;
INPUT BUBBLES = NO;
INPUT LABELS = NO;
INPUT CLOSEWEIGHTTODAY = NO;
INPUT CLOSEWEIGHTYEST = yes;
INPUT CLOSEWEIGHTTWODAY = yes;
PLOT HI = HIGH(PERIOD = AGG);
PLOT LO = LOW(PERIOD = AGG);
PLOT YHI = HIGH(PERIOD = AGG)[1];
PLOT YLO = LOW(PERIOD = AGG)[1];
PLOT FIFTYPCT = if cloSEWEIGHTTODAY then (hi + lo + close(period = agg)) / 3 else (HI + LO) / 2;
PLOT YESTERDAYFTYPCT = if cloSEWEIGHTYEST then (yhi + ylo + close(period = agg)[1]) / 3 else (YHI + YLO) / 2;
DEF WHICHHI = IF YHI > YHI[1] THEN YHI ELSE YHI[1];
DEF WHICHLO = IF YLO < YLO[1] THEN YLO ELSE YLO[1];
DEF TODAY = if (GetDay() == GetLastDay()) or (GetlastDay() - 1 == getday()) then yes else no;
DEF BUBBLESPOT = if IsNaN(open[-1]) && !IsNaN(open) then (BarNumber() - 1) else DOUBLE.NAN;
PLOT FIFTYPCTTWODAY = if ClOSEWEIGHTTWODAY then (WHICHHI + WHICHLO + close(period = AGG)[1]) / 3 else (WHICHHI + WHICHLO) / 2;
HI.SETLINEWeight(2);
LO.SETLINEWeight(2);
HI.SETDefaultColor(CREATECOlor(166,130,166));
LO.SETDefaultColor(CREATECOlor(166,130,166));
YLO.SETDefaultColor(CREATECOlor(146,120,146));
YHI.SETDefaultColor(CREATECOlor(146,120,146));
FIFTYPCT.setDefaultColor(Color.GRAY);
FIFTYPCT.setpaintingStrategy(paintingStrategy.DASHES);
YESTERDAYFTYPCT.setDefaultColor(Color.Dark_GRAY);
YESTERDAYFTYPCT.setpaintingStrategy(paintingStrategy.SQUARES);
FIFTYPCTTWODAY.setDefaultColor(Color.GRAY);
FIFTYPCTTWODAY.setpaintingStrategy(paintingStrategy.TRIANGLES);
ADDLABEL(LABELS, "HI/50/LO=" + HI + "/ " + FIFTYPCT +"/ " + LO, CREATECOlor(166,130,166));
ADDLABEL(LABELS, "2D 50%=" + FIFTYPCTTWODAY, COLOR.GRAY);
ADDLABEL(LABELS, "YEST=" + YHI + "/ " + YESTERDAYFTYPCT + "/ " + YLO, CREATECOlor(146,120,146));

def x = BarNumber();

ADDCHARTBUBBLE(BUBBLES AND TODAY AND x == HighestAll(x), HI, "HI",CREATECOlor(166,130,166), YES);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND x == HighestAll(x), LO, "LO",CREATECOlor(166,130,166), NO);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND x == HighestAll(x), YHI, "YEST HI",CREATECOlor(146,120,146), if close > YHI then NO else YES);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND x == HighestAll(x), YLO, "YEST LO",CREATECOlor(146,120,146), if close > YLO then NO else YES);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND x == HighestAll(x), FIFTYPCT, "TODAY 50%", COLOR.GRAY, IF CLOSE > FIFTYPCT THEN NO ELSE YES);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND x == HighestAll(x), YESTERDAYFTYPCT, "YEST 50%", COLOR.GRAY, IF CLOSE > YESTERDAYFTYPCT THEN NO ELSE YES);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND x == HighestAll(x), FIFTYPCTTWODAY, "2D 50%", COLOR.GRAY, IF CLOSE > FIFTYPCTTWODAY THEN NO ELSE YES);
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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