How to hide all but the last chart bubble?

LetsMakeMoney

New member
VIP
I have a study that plots 8, 21, 34, 55, and 89 ema averages. These are the averages that John Carter said he uses in one of his videos. When the 8 and 21 ema cross, the script calculates the percent difference between the 8 ema's current bar and the previous bar. The script puts a bubble everywhere there is a cross, but I only want the last bubble to show for the last 8/21 ema crossover. The idea behind this study is to get a feel for how strong the cross is. The percent changes are so small that I multiplied
the calculation by a factor of 100 to get more readable numbers. The higher the number the stronger the cross. Here is the script. I've tried but can't figure out how
to eliminate all the bubbles except the last one.

Code:
declare lower;
input first =8;
input second = 21;
input third = 34;
input fourth = 55;
input fifth = 89;
def limit_bubble_display = 1;
def bubbles_to_display = 1;
plot num1 = ExpAverage(close,first);
num1.SetDefaultColor(Color.GREEN);
plot num2 = ExpAverage(close,second);
num2.SetDefaultColor(Color.WHITE);
plot num3 = ExpAverage(close,third);
num3.SetDefaultColor(Color.MAGENTA);
plot num4 = ExpAverage(close,fourth);
num4.SetDefaultColor(Color.CYAN);
plot num5 = ExpAverage(close,fifth);
num5.SetDefaultColor(Color.RED);
def num1crossabove = if num1 crosses above num2 then 1 else 0 ;
plot N1CA = num1crossabove;
N1CA.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
N1CA.SetDefaultColor(color.green);
def num1crossbelow = if num1 crosses below num2 then 1 else 0;
plot N1CB = num1crossbelow;
N1CB.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
N1CB.SetDefaultColor(color.red);
# Multiplied the percent difference by a factor of 100 to get numbers more easily read and compared.
# The higher numbers represent steeper crosses on a relative basis.
def crosspercent = if N1CA or N1CB then ((num1 - num1[1])/num1[1])*100 else double.nan;
AddChartBubble(N1CA or N1CB, high, crosspercent,if num1crossabove then Color.light_green else color.red, no);
 
I have a study that plots 8, 21, 34, 55, and 89 ema averages. These are the averages that John Carter said he uses in one of his videos. When the 8 and 21 ema cross, the script calculates the percent difference between the 8 ema's current bar and the previous bar. The script puts a bubble everywhere there is a cross, but I only want the last bubble to show for the last 8/21 ema crossover. The idea behind this study is to get a feel for how strong the cross is. The percent changes are so small that I multiplied
the calculation by a factor of 100 to get more readable numbers. The higher the number the stronger the cross. Here is the script. I've tried but can't figure out how
to eliminate all the bubbles except the last one.

Code:
declare lower;
input first =8;
input second = 21;
input third = 34;
input fourth = 55;
input fifth = 89;
def limit_bubble_display = 1;
def bubbles_to_display = 1;
plot num1 = ExpAverage(close,first);
num1.SetDefaultColor(Color.GREEN);
plot num2 = ExpAverage(close,second);
num2.SetDefaultColor(Color.WHITE);
plot num3 = ExpAverage(close,third);
num3.SetDefaultColor(Color.MAGENTA);
plot num4 = ExpAverage(close,fourth);
num4.SetDefaultColor(Color.CYAN);
plot num5 = ExpAverage(close,fifth);
num5.SetDefaultColor(Color.RED);
def num1crossabove = if num1 crosses above num2 then 1 else 0 ;
plot N1CA = num1crossabove;
N1CA.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
N1CA.SetDefaultColor(color.green);
def num1crossbelow = if num1 crosses below num2 then 1 else 0;
plot N1CB = num1crossbelow;
N1CB.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
N1CB.SetDefaultColor(color.red);
# Multiplied the percent difference by a factor of 100 to get numbers more easily read and compared.
# The higher numbers represent steeper crosses on a relative basis.
def crosspercent = if N1CA or N1CB then ((num1 - num1[1])/num1[1])*100 else double.nan;
AddChartBubble(N1CA or N1CB, high, crosspercent,if num1crossabove then Color.light_green else color. Red, no);
Apparently, this is a hard nut to crack. I've searched for hours and can't find a solution for what I'm trying to do. For the time being, just for readability, I've ported the code to an upper study. At least the bubbles aren't so overlapping as much.
 

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