# First Red Candle Above 10ema

##### New member
I’m trying to write a scanner that will finds stocks that were trading below the 10ema and then crossed above the 10ema and have the first red candle that closed above the 10ema. It can have as many green candles, I’m looking for that first red candle.

I tried different ways, but can’t figure this one out. Any help or tips would be appreciated

Solution
I’m trying to write a scanner that will finds stocks that were trading below the 10ema and then crossed above the 10ema and have the first red candle that closed above the 10ema. It can have as many green candles, I’m looking for that first red candle.

I tried different ways, but can’t figure this one out. Any help or tips would be appreciated

See if this helps you

Ruby:
``````def ema1     = ExpAverage(close, 10);
def emacross = if close crosses above ema1[1] then 1 else if emacross[1] == 1 and close > ema1 and close > open then 1 else 0;
plot scan    = emacross[1] == 1 and emacross == 0 and open > close;
scan.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);``````
I’m trying to write a scanner that will finds stocks that were trading below the 10ema and then crossed above the 10ema and have the first red candle that closed above the 10ema. It can have as many green candles, I’m looking for that first red candle.

I tried different ways, but can’t figure this one out. Any help or tips would be appreciated

See if this helps you

Ruby:
``````def ema1     = ExpAverage(close, 10);
def emacross = if close crosses above ema1[1] then 1 else if emacross[1] == 1 and close > ema1 and close > open then 1 else 0;
plot scan    = emacross[1] == 1 and emacross == 0 and open > close;
scan.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);``````

87k+ Posts
195 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?