Relocate AddChartBubble for MACD and SMA?



New member
How do I get a Bubble to appear outside the chart like other Bubbles for studies such as MACD, SMA,etc?
I have did some research but can't find any code to relocate the Bubble outside the chart.
I created code to show the Close with a Bubble. But the Bubble is inside the chart.

#Daily Close

input aggregationPeriod = AggregationPeriod.DAY;
input showOnlyLastPeriod = yes;

def prevPrice = close(period = aggregationPeriod)[-1];
def price = close(period = aggregationPeriod);

plot DailyClose = if showOnlyLastPeriod and !IsNaN(prevPrice) then Double.NaN else price;
def x = DailyClose;

AddChartBubble((x + 8) > DailyClose, close, close, Color.yellow, yes);
Last edited by a moderator:


Well-known member
@tlee404 Noticed that your code definition for the variable "prevPrice", you're indexing 1 bar into the future. To index this as a bar before, your definition needs to be changed to

def prevPrice = close(period = aggregationPeriod)[1];
Your other comment about locating the bubble outside the chart - I take it you mean you'd like to display this in the expansion space?
Note that bubbles are located using an X, Y axis where X is the first variable usually denoted by a barNumber() or horizontal location and Y is the vertical or price location. Looking at your first variable for AddChartBubble() - that evaluates to a boolean rather than a horizontal location.

Hope that helps


New member
It appears my Question was truncated or changed. It should have been the same as the 1st sentence of my post.

After further research found the following.
  • The (x +8) > Daily Close, was not necessary, it only needed an x, you cannot use Close for it .
  • AddChartBubble((x + 8) > DailyClose, close,: if you add or subtract such as close +5, it will move the vertical position of the bubble.
But the amount moved seems to be dependent on the price of the stock and is not constant.
- It appears the bubble will appear on the right side of the candle, however if you don't have enough space on the right side of the
chart to fit it, it will appear on the left side. This causes a problem as the close is the last candle on the chart so if you don't leave at least 6 extra
candles spaces after the close the bubble will appear on the left side of the close. This makes it a problem when the previous prices are above the
closing price of the day. As the bubble may conflict with other candles or bubbles. That is the reason I would have liked to have the bubble
on the outside edge of the chart such as MACD, SMA,etc.

If your wondering, I coded this because I use Heikin Ashi candles, and as you know the closing price it shown is not the real closing price.
And I get tired of having to take the time to move my head to see the real closing price at the far left side of the chart.
Also, I have a limited coding experience., but I can patch things together, which is how I created this after doing some research and
sending hours to create it. You can be sure I will be asking for advice in the future. Hope this can help someone in the future.
Last edited:
Thread starter Similar threads Forum Replies Date
Branch Questions 6
Similar threads
AddChartBubble on 10 EMA