First time close under a moving average in x number of bars

EDDY GARCIA

New member
Im trying to setup a scan looking for trends that are on the verge of dying. so im looking for strong stocks that have respected a certain moving average, we'll say the 10 week.

1) its consecutively closed over the 10 week ma for 10 weeks, but week 11 now has closed below it. Do I need to specify a lookback period of 11 in this case and do I need to compare close to each of the 11 periods moving averages and count the streak using compound value? sorry if its confusing Ive been messing with this one for a bit.
 

tomsk

Well-known member
VIP
@EDDY GARCIA Here is a scan that consecutively closed above the 10 week moving average but for the 11th week closed below it.
Make sure you run this on a WEEKLY aggregation on the scanner.
I just scanned the S&P 500 and obtained 3 hits - HCP, HD and SO

# Dying Trends Scan
# tomsk
# 11.11.2019

def MA = Average(close, 10);
plot scan = sum(close[1] > MA[1], 10) == 10 and close < MA;
# END SCAN
 
Last edited:

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.
Top