# Scanner where there's a triple MA crossover within the last X number of bars

#### str8cash

##### New member
Hi,
I have a scan that looks for stocks that have a 5, 10, 20 MA avg cross over. Pretty simple. What I'm looking for is how to update my scan so that I can find stocks that have recently done it within the last X bars on the daily timeframe. And vice versa if there's a bearish crossover. Here's my code for the postive crossover:

# Scan for stocks that are currently in triple crossover condition
def MAs = average(close, 5);
def MAm = average(close, 10);
def MAl = average(close, 20);
plot Edn = MAs > MAm and MAm > MAl;

Thanks

Solution
Hi,
I have a scan that looks for stocks that have a 5, 10, 20 MA avg cross over. Pretty simple. What I'm looking for is how to update my scan so that I can find stocks that have recently done it within the last X bars on the daily timeframe. And vice versa if there's a bearish crossover. Here's my code for the postive crossover:

# Scan for stocks that are currently in triple crossover condition
def MAs = average(close, 5);
def MAm = average(close, 10);
def MAl = average(close, 20);
plot Edn = MAs > MAm and MAm > MAl;

Thanks
Ruby:
``````# Scan for stocks that are currently in triple crossover condition
def MAs = average(close, 5);
def MAm = average(close, 10);
def MAl = average(close, 20);
def Edn = MAs > MAm and MAm > MAl;
plot...``````
Hi,
I have a scan that looks for stocks that have a 5, 10, 20 MA avg cross over. Pretty simple. What I'm looking for is how to update my scan so that I can find stocks that have recently done it within the last X bars on the daily timeframe. And vice versa if there's a bearish crossover. Here's my code for the postive crossover:

# Scan for stocks that are currently in triple crossover condition
def MAs = average(close, 5);
def MAm = average(close, 10);
def MAl = average(close, 20);
plot Edn = MAs > MAm and MAm > MAl;

Thanks
Ruby:
``````# Scan for stocks that are currently in triple crossover condition
def MAs = average(close, 5);
def MAm = average(close, 10);
def MAl = average(close, 20);
def Edn = MAs > MAm and MAm > MAl;
plot scan = Edn within 3 bars ;``````

Scanner: Previous Bar is High Of Day Questions 2
short time frame momentum scanner Questions 3
EMA 20/50 crossover Scanner Questions 2
Consecutive Dividend Scanner? Questions 0
8 EMA Scanner Questions 1

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