Contraction - Continuation pattern scanner

cascadetrader88

New member
Hi All,

I recently came upon this forum and have found it immensely helpful to find new indicators to use. I found scan criteria I would like to use, but it's for a paid scanner that I don't have access to. I was hoping to build something comparable to this for ToS, but I've been having a hard time implementing the criteria using the customer scanner. I don't know anything about writing code and I was wondering if anyone here would be able to build a scan like this in Thinkscript. Thanks in advance to anyone who tries to build it!!

Price vs 52 wk-high is between 75-100%
Avg 3-month vol >500000
Last Close >.5
Price is at least 150% over 200D SMA
Price is at least 90% over 50D SMA
Price is at least 250% over 52-wk low
1-year return vs S&P 500 >40
1-year return vs sector >60
6-month return >50

edit: typo
 
Last edited:
Hi All,

I recently came upon this forum and have found it immensely helpful to find new indicators to use. I found scan criteria I would like to use, but it's for a paid scanner that I don't have access to. I was hoping to build something comparable to this for ToS, but I've been having a hard time implementing the criteria using the customer scanner. I don't know anything about writing code and I was wondering if anyone here would be able to build a scan like this in Thinkscript. Thanks in advance to anyone who tries to build it!!

Price vs 52 wk-high is between 75-100%
Avg 3-month vol >500000
Last Close >.5
Price is at least 150% over 200D SMA
Price is at least 90% over 50D SMA
Price is at least 250% over 52-wk low
1-year return vs S&P 500 >40
1-year return vs sector >60
6-month return >50

edit: typo
This is an attempt. (I re-sorted to get all the Daily, Weekly, Monthly, Yearly scans together). You can do 4 queries, one per time frame.

Add 4 custom studies in Stock Hacker, and change the time frames to Daily, Weekly, Monthly, and Yearly.
after that, paste in the code sections below.


Caveat 1 of 3. I'm not aware of how to dynamically pull the sector that a stock is a member of, so I hard-coded the sector
See threads:
https://usethinkscript.com/threads/sector-lookup-label.7255/
https://usethinkscript.com/threads/...-a-ticker-with-its-corresponding-sector.7851/
https://usethinkscript.com/threads/how-to-display-the-equitys-sector.8415/

Caveat 2 of 3. Everywhere it says return, I'm assuming percentage gain in price only

Caveat 3 of 3. using SPY as proxy for S&P 500.

# scan 1 of 4. [DAILY TIME FRAME]
Code:
# Last Close >.5
# Price is at least 150% over 200D SMA
# Price is at least 90% over 50D SMA
input price = close;
input minClose = .50; # $.50
input minPctLongSMA = 1.5; #150%
input minPctShortSMA = .90; #90%
input longSMALength = 200;
input shortSMALength = 50;

def longSMA = Average(price, longSMALength);
def shortSMA = Average(price, shortSMALength);


def minLastClose = price > minClose;
def abovepctLongSMA = price >= minPctLongSMA * longSMA;
def abovepctShortSMA = price >= minPctShortSMA * shortSMA;

plot scan = minLastClose && abovepctLongSMA && abovePctShortSMA;



# scan 2 of 4. [WEEKLY TIME FRAME]
Code:
#Price vs 52 wk-high is between 75-100%
# Price is at least 250% over 52-wk low

input minpcthigh = .75; # 75%
input maxpcthigh = 1.0; #100%
input minpctlow = 2.5; #250%

def price = close; #price
def high52week = highest(high, 52); #52-week-high
def low52week = lowest(low, 52); # 52 week low

def betweenpcthigh = price >= minpcthigh *high52week && price <= maxpcthigh *high52week;
def abovepctlow = price >= minpctlow * low52week;

plot scan = betweenpcthigh && abovepctlow;

# Scan 3 of 4. [MONTHLY TIME FRAME]
Code:
# Avg 3-month vol >500000
# 6-month return >50
input minVolume = 500000;
input recentMonths = 3;
input  monthsago = 6;
input minReturn = 1.50; # 50% return would imply 150% higher than it was

def avgVolumeShort = Average(volume, recentMonths);
def closeMonthsAgo = close[monthsAgo];

def targetVolume = avgVolumeShort > minVolume;

def targetReturn = Close > minReturn * closeMonthsAgo;

plot scan = targetVolume && targetReturn;

# Scan 4 of 4. [YEARLY TIME FRAME]
Code:
# 1-year return vs S&P 500 >40
# 1-year return vs sector >60 (note: sector cannot be queried via thinkscript)
# so the sector is hard-coded via input.
# https://usethinkscript.com/threads/how-to-display-the-equitys-sector.8415/

input yearsAgo = 1;
input pctexceedSP = .40; #40%
input pctExceedSector = .60; # 60%
input CorrelationSP = "SPY";
input CorrelationSector = "XLK";

def symbolReturn = close/close[yearsAgo];
def SPReturn = close(correlationSP)/(close(correlationSP)[yearsAgo]);
def SectorReturn = close(CorrelationSector)/(close(correlationSector)[yearsAgo]);

def beatSP = symbolReturn - SPReturn > pctExceedSP;
def beatSector = symbolReturn - SectorReturn > pctExceedSector;

plot scan = beatSP && beatSector;

Running this after-market on 3/23/2022, I get 75 symbols when scanning "All Stocks" (see screenshot at the end showing the scan and the scan results).


3H3KyMZ.png
 

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