Macd Chart Bubbles

Below is link to previous thread for a macd chart bubble indicator that works well. I am wondering if there is a way to update it to have choice to show all bubbles or just current one? Thanks.

https://usethinkscript.com/threads/...el-watchlist-for-thinkorswim.7745/post-129775

You can control whether to limit and how many at the input screen.

Screenshot 2023-11-17 131215.png
Code:
input limitplot     = yes;
input limit_x_plots = 1;
input pricecolor = yes;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;

def Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
def Avg = MovingAverage(averageType, Value, MACDLength);

plot Diff = Value - Avg;

Diff.Hide();
Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.Color("Positive and Up") else Diff.Color("Positive and Down") else if Diff < Diff[1] then Diff.Color("Negative and Down") else Diff.Color("Negative and Up"));

AssignPriceColor(if !pricecolor then Color.CURRENT else Diff.TakeValueColor());

def upcond    = if Diff crosses above 0 then 1 else 0;
def upcount   = if BarNumber() == 1 then 0 else if upcond then upcount[1] + 1 else upcount[1];
plot UpSignal = if limitplot and HighestAll(upcount) - upcount  <= limit_x_plots - 1 then upcond else if !limitplot then upcond else Double.NaN;

AddChartBubble(UpSignal, low, "Buy", Color.LIGHT_GREEN, no);

def dncond      = if Diff crosses below 0 then 1 else 0;
def dncount     = if BarNumber() == 1 then 0 else if (dncond) then dncount[1] + 1 else dncount[1];
plot downSignal = if limitplot and HighestAll(dncount) - dncount  <= limit_x_plots - 1 then dncond else if !limitplot then dncond else Double.NaN;

AddChartBubble(downSignal, high, "Sell", Color.LIGHT_RED, 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
318 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