Add a Chart Bubble when 50SMA crosses below 100SMA

Branch

Member
I would like to have have a bubble show on my chart when the 50MA crosses below the 100MA; the bubble text will be state "Short". Can anyone help me with this?
 
Adjust the inputs to your liking.

Code:
# Moving Average Crossover With Arrows, Alerts, Crossing Count and Bubble at Cross
# Mobius
# Chat Room Request 01.25.2017

input price = close;
input fastLength = 20;
input slowLength = 50;
input averageType = AverageType.EXPONENTIAL;

plot FastMA = MovingAverage(averageType, price, fastLength);
plot SlowMA = MovingAverage(averageType, price, slowLength);
FastMA.SetDefaultColor(GetColor(1));
SlowMA.SetDefaultColor(GetColor(2));

plot ArrowUp = if FastMA crosses above SlowMA
               then low
               else double.nan;
     ArrowUP.SetPaintingStrategy(PaintingStrategy.Arrow_UP);
     ArrowUP.SetLineWeight(3);
     ArrowUP.SetDefaultColor(Color.Green);
plot ArrowDN = if FastMA crosses below SlowMA
               then high
               else double.nan;
     ArrowDN.SetPaintingStrategy(PaintingStrategy.Arrow_DOWN);
     ArrowDN.SetLineWeight(3);
     ArrowDN.SetDefaultColor(Color.Red);
Alert(ArrowUp, " ", Alert.Bar, Sound.Chimes);
Alert(ArrowDN, " ", Alert.Bar, Sound.Bell);
def countUP = if FastMA crosses above SlowMA
              then 1
              else if FastMA > SlowMA
                   then countUP[1] + 1
              else if ArrowDN
                   then 0
                   else countUP[1];
AddLabel(1, "Count UP = " + countUP, color.white);
def CrossBar = if FastMA crosses SlowMa
               then barNumber()
               else double.nan;
AddChartBubble(barNumber() == HighestAll(CrossBar), FastMA, "Cross", color.cyan);
# End Code
 

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

You said you wanted to be taught. So look where averagetype is used in the study. And change the averagtype for the plot you want to change. Looks like you wanted a 50 EMA cross of 75 SMA. So think how you would do that.
 
don't need help with that part exactly, I mean, like for example I just want to alert, when SMA(A) cross EMA(B).
like a message alert, so how do i go about it?... like can you guide me a bit?

You said you wanted to be taught. So look where averagetype is used in the study. And change the averagtype for the plot you want to change. Looks like you wanted a 50 EMA cross of 75 SMA. So think how you would do that.
 
@Buckbull You can setup a scanner and save it as a watchlist.

u3WnEBz.png


Here is the thinkScript code for the scanner:

Code:
close crosses SimpleMovingAvg("length" = 20)."SMA"
 

Attachments

  • u3WnEBz.png
    u3WnEBz.png
    115.6 KB · Views: 158
@Buckbull hang in there! This forum is the best forum I ever been apart of and I have been at this since TD Ameritrade brought/partnered with ThinkOrSwim. And I am just now learning the scripting (I have been wasting time doing other things in my life). BenTen provided you a great link.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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