EMA crossover

CraftyPicks

New member
I've been looking for a 3 types of EMA crossover indicator but have been unlucky.

Example, i would like a buy/sell indicator signal when these conditions are met.

If 21 EMA crosses 50 EMA while 200 is trending up then i get a buy signal.
If 200 EMA crosses 50 EMA and 21 on an uptrend then i get sell signal.

Thick blue line is the 200 ema
Yellow line is the 50 ema
thin blue line is the 20 ema

i would like a signal every time these conditions are met
 

Attachments

  • ema.png
    ema.png
    140.8 KB · Views: 192
  • ema2.png
    ema2.png
    131.2 KB · Views: 173
  • ema3.png
    ema3.png
    140.6 KB · Views: 178
I think I've got your conditions coded correctly, though the second one for sell signals took a few reads through to get.

Code:
declare upper;

input fast = 21;
input slow = 50;
input filter = 200;

def fast_ema = MovAvgExponential(price = CLOSE, length = fast);
def slow_ema = MovAvgExponential(price = CLOSE, length = slow);
def filter_ema = MovAvgExponential(price = CLOSE, length = filter);

plot buy = if fast_ema crosses slow_ema and filter_ema > filter_ema[1] then low else double.nan;
buy.SetPaintingStrategy(PaintingStrategy.ARROW_UP);

plot sell = if filter_ema crosses  slow_ema and fast_ema > fast_ema[1] then high else double.nan;
sell.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

-mashume
 

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