Moving Average Crossovers For ThinkOrSwim

@hnallamala
Moving Average Scan Shared Scan Link: http://tos.mx/YtpQPAg Click here for --> Easiest way to load shared links
Candle drops below 21 SMA with in 9 bars and crosses above 21 SMA and crosses above 8 SMA
npH9Hin.png

b1.png
 

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

I want a study to show when either close[0] crosses 50MA OR close[0] crosses 100MA OR close[0] crosses BOTH 50MA and 100MA. close[1] should be less than both the 50MA and the 100MA.

Can anybody make these conditions into a code? I would really appreciate it!
 
@dmillz I moved your question here because there are 12 pages of crossing moving averages. Sure to have something that fits your needs.
 
Anyone know how to change it to 9 EMA crosses 20 SMA? can you have two averages in a code?
Yes, it is possible, take a look at the code I posed in https://usethinkscript.com/threads/custom-moving-average-for-thinkorswim.8269/

While it is not exactly what you are looking, that code has the ability to show 5 different MA lengths and you can select Simple/Exp/Weighted/Wilder/HULL. It's not per MA length but for all of that. But it should give you an idea of what you need to change for your strategy.
 
This is just a simple indicator for moving average crossover but added scanner, cloud, and alerts for additional visual effect and enhancement.

For example, if 5/10 EMA crossover is your strategy, then this indicator plot an up arrow on the golden cross and down arrow on the death cross. You can also use the scanner to scan for stocks with EMA crossover and the built-in alerts to let you know as it happens.

1XlzIJA.png


thinkScript Code

Rich (BB code):
# Moving Average Crossover With Arrows, Alerts, Crossing Count and Bubble at Cross
# Mobius
# Chat Room Request 01.25.2017
# Modified a bit by BenTen

input price = close;
input fastLength = 8;
input slowLength = 21;
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);

AddCloud(FastMA, SlowMA, Color.GREEN, Color.RED);
# End Code

Shareable Link

https://tos.mx/2ZED6i
How do you use it as a scan?
 
@brw71585 I moved your post to this thread. You will find 13 pages of how to chart, scan and watchlist your EMA crossover.
 
Hi everyone!!

I would like to display a Text above the bar that has the highest value in a range of bars, there are between SMA20 cross above of SMA50 and SMA20 cross down of SMA50. How can do that?

I have study the "AddchartBubble" or "AddLabel", but these can not let me do that.

I appreciate if you can help me.

Thanks!!
 
Hi everyone!!

I would like to display a Text above the bar that has the highest value in a range of bars, there are between SMA20 cross above of SMA50 and SMA20 cross down of SMA50. How can do that?

I have study the "AddchartBubble" or "AddLabel", but these can not let me do that.

I appreciate if you can help me.

Thanks!!
AddchartBubble is the only format ToS provides to place text in a chart.
 
Last edited:
I want to be notified when 15 and 50 EMA's cross the 200 EMA, not when a candle crosses and EMA. Please check out this screen shot, it's the areas I circled in red. https://docs.google.com/document/d/1h5uMiTzxcExb4oIKzWj7c6IGrrVKicO-YjUV0QJj9Bw/edit?usp=sharing
Code:
def ema200 = ExpAverage(close, 200);
def ema50 = ExpAverage(close, 50);
def ema15 = ExpAverage(close, 15);
plot scan = ema15 crosses above ema200 and ema50 cross above ema200 ;
FYI, Having a scan alert when ema15 and ema50 cross at the exact same point this scan will have limited results.
 
Is there a way to make a moving average change color when price crosses above it? Similar to the standard "UpSignal" with arrows that are built into the standard EMA, but instead of arrows, I just want the line itself to change colors.
 
Is there a way to make a moving average change color when price crosses above it? Similar to the standard "UpSignal" with arrows that are built into the standard EMA, but instead of arrows, I just want the line itself to change colors
The function to change the moving average plot line is AssignValueColor.
Without a script. No other assistance is possible.
 
Hi, How to scan for a stock 9EMA crosses over 21EMA, with the condition of current price is above 50EMA and 200EMA.
Please can somebody help me?
 
Hi, How to scan for a stock 9EMA crosses over 21EMA, with the condition of current price is above 50EMA and 200EMA.
Please can somebody help me?
Code:
def ema200 = ExpAverage(close, 200);
def ema50 = ExpAverage(close, 50);
def ema21 = ExpAverage(close, 21);
def ema9 = ExpAverage(close, 9);
plot scan = ema9 crosses above ema21 and close > ema200 and close > ema50  ;
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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