Plotting Bubbles To The Right of Horizonatl Lines

cdgardner

New member
I am attempting to plot chart bubbles to the right of opening range breakout values but the bubbles plot over the last bar on the chart. The formula I am using is:

Input ShowBubble = yes;

Input BarsInFuture = 3;

Def bif = BarsInFuture;

def SR = showBubble and !IsNaN(close) and IsNaN(close [-1] ) && HighestAll(BarNumber());

AddChartBubble(SR, R1, “Buy:” + R1, Color.UPTICK, yes);

AddChartBubble(SR, Settlement, “Open:” + Settlement, Color.YELLOW, no);

AddChartBubble(SR, S1, “Sell:” + S1, Color.DOWNTICK, no);

When I try to apply code to advance the bubble to bars in the future, bubble will not display. This is the code I have trying to get to work:
Input ShowBubble = yes;

Input ShowBubble = yes;

input BarsInFuture = 3;

def bif = BarsInFuture;

def x = isNaN(close[bif]) and !isNaN(close[bif+1]);

def vert = R1[bif+1];

AddChartBubble(ShowBubble and x, vert, “Buy:” + R1, color.UPTICK, yes);

Any help with setting the bubbles to the right of the last price bar would be greatly appreciated.
 
Solution
I am attempting to plot chart bubbles to the right of opening range breakout values but the bubbles plot over the last bar on the chart. The formula I am using is:

Input ShowBubble = yes;

Input BarsInFuture = 3;

Def bif = BarsInFuture;

def SR = showBubble and !IsNaN(close) and IsNaN(close [-1] ) && HighestAll(BarNumber());

AddChartBubble(SR, R1, “Buy:” + R1, Color.UPTICK, yes);

AddChartBubble(SR, Settlement, “Open:” + Settlement, Color.YELLOW, no);

AddChartBubble(SR, S1, “Sell:” + S1, Color.DOWNTICK, no);

When I try to apply code to advance the bubble to bars in the future, bubble will not display. This is the code I have trying to get to work:
Input ShowBubble = yes;

Input ShowBubble = yes;

input BarsInFuture = 3;

def...
I am attempting to plot chart bubbles to the right of opening range breakout values but the bubbles plot over the last bar on the chart. The formula I am using is:

Input ShowBubble = yes;

Input BarsInFuture = 3;

Def bif = BarsInFuture;

def SR = showBubble and !IsNaN(close) and IsNaN(close [-1] ) && HighestAll(BarNumber());

AddChartBubble(SR, R1, “Buy:” + R1, Color.UPTICK, yes);

AddChartBubble(SR, Settlement, “Open:” + Settlement, Color.YELLOW, no);

AddChartBubble(SR, S1, “Sell:” + S1, Color.DOWNTICK, no);

When I try to apply code to advance the bubble to bars in the future, bubble will not display. This is the code I have trying to get to work:
Input ShowBubble = yes;

Input ShowBubble = yes;

input BarsInFuture = 3;

def bif = BarsInFuture;

def x = isNaN(close[bif]) and !isNaN(close[bif+1]);

def vert = R1[bif+1];

AddChartBubble(ShowBubble and x, vert, “Buy:” + R1, color.UPTICK, yes);

Any help with setting the bubbles to the right of the last price bar would be greatly appreciated.

you posted a partial code, which makes it difficult to fix a broken code, even a simple one.

--------------------

when trying to figure out why things don't work, separate formulas into multiple parts, and set up a bubble to display those variables.

i added a formula for the highestall() part of a formula , to see the values.

Code:
def hbn = highestAll(BarNumber());
def SR = showBubble and !IsNaN(close) and IsNaN(close [-1] ) && HighestAll(BarNumber());
addchartbubble(1,50,
bn + "\n" +
hbn + "\n" +
sr
, color.yellow, no);


this formula has a couple things wrong with it.
def SR = showBubble and !IsNaN(close) and IsNaN(close [-1] ) && HighestAll(BarNumber());

it is a boolean formula, but the last part is not a condition, it is a number.
&& HighestAll(BarNumber());

and it is the barnumber of the bar placeholder that is at the right most edge on the chart, not the last visible bar.

so, && HighestAll(BarNumber()) is a non zero, so it is always evaluated as true.

this is how to compare a variable to a barnumber, but value this won't work in your formula.
and HighestAll(BarNumber()) == barnumber()

this is all you need to find the last visible bar.
!IsNaN(close) and IsNaN(close[-1] )


to verify the value of what HighestAll(BarNumber()) is ,
( i used 50 for price, so pick a stock around 50 or adjust the chart screen to see the bubbles)
this will draw a bubble, on the right edge of the chart.

Code:
addchartbubble(
(BarNumber() == HighestAll(BarNumber()) , 50,
barnumber() + "\n" +
"highest"
, color.yellow, no);



in your last line,
AddChartBubble(ShowBubble and x, vert, “Buy:” + R1, color.UPTICK, yes);
r1 doesn't have an offset , so it will try to read a value, after the last bar, and have an error.

r1 isn't defined so i had to add a formula
def r1 = close;


working code

Code:
def r1 = close;
Input ShowBubble = yes;
Input BarsInFuture = 3;
Def bif = BarsInFuture;

def x = isNaN(close[bif]) and !isNaN(close[bif+1]);
def vert = R1[bif+1];
AddChartBubble(ShowBubble and x, vert, “Buy:” + r1[bif+1], color.UPTICK, yes);



ref bif codes
https://usethinkscript.com/threads/only-display-on-current-candle.6343/#post-61497

updated
https://usethinkscript.com/threads/display-bubble-on-the-right-edge.3037/#post-66620
 
Solution

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
338 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