scan for narrow range candle sticks

cocojumbo

Member
Plus
Would anyone be able to help with a scan for narrow range candle sticks? Basically 20ma and 200ma tightening with candlesticks in-between?
 
Solution
I was actually watching those exact videos and was wondering how one could scan for something like this

Because Mr. Velez doesn't define the narrow state exactly, here's a scan for stocks where the 20 Period Simple Moving Average and 200 period Simple Moving Average are within 5% deviations of each other, based on a comment by EnclaveDCLXVI in the Youtube comment section:

"There seems to only be one missing ingredient; the scan. Too many results for a 5% max deviation between the moving averages. There's more needed to this set-up than is recorded... the scan.

Note that the charts in his examples have extended-hours OFF.

SCAN
Code:
# scan for 20 SMA is within 5% deviation of the 200 SMA
# by...
Would anyone be able to help with a scan for narrow range candle sticks? Basically 20ma and 200ma tightening with candlesticks in-between?

Don't yet have enough information to assist you.

Can you please share:
1) Your definition of "narrow", "in-between" and "tightening"
2) when you say MA, are you referring to the simple moving average, or one of the exotic exponential, double exponential, triple exponential, hull, etc?
3) Picture(s) that include the narrow, inbetween, and tightening
4) What you've done so far

I know of an Oliver Velez who talks about a "narrow state" that involves the 20 period simple moving average and the 200 period simple moving average, but the examples he posts are "subjective" and he doesn't define it precisely. It feels like "you know it when you see it". What you've provided so far is also subjective, so need some objective criteria in what you mean by narrow (error, deviation, percentile, etc.), in-between (above, below, etc.), tightening (what exactly is tightening?) etc. that can be relayed to ThinkOrSwim.

iGhHTDJ.png


 
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

can you specify something like sma20 crosses above sma200 but is less than 3% away from it ( that would specify the narrow space between them)
You could but I couldn't really see the purpose. Different time frames would return different results. So you would have to stick to one time frame, scan within 3% and (i believe) combine it with a study library (bollinger bands, keltner channels, etc). That would be my first approach

Maybe...
if SMA200 && SMA20 is within/between value=.3 then 1 else 0;

but if you change time frames it would return different results.
 
thanks appreciate that, can that same within/between value be use to track the last 30 minutes of the previous day?
Yeah. Although its pseudo code, so its more of a blueprint and wouldnt execute proper. And HIGH && LOW are different than moving averages. Looking into "high()", "low()", "getHighest()" and "getLowest()".
 
def SMA200 = SimpleMovingAvg(price=close, length=200);
def SMA20 = SimpleMovingAvg(price=close, length=20);

if SMA200 crosses above SMA20 then 1 else 0;
#if SMA20 crosses above SMA200 then 1 else 0;
#if SMA20 crosses SMA200 then 1 else 0;
thank you for the attempt, this returned error. something missing?
 
Don't yet have enough information to assist you.

Can you please share:
1) Your definition of "narrow", "in-between" and "tightening"
2) when you say MA, are you referring to the simple moving average, or one of the exotic exponential, double exponential, triple exponential, hull, etc?
3) Picture(s) that include the narrow, inbetween, and tightening
4) What you've done so far

I know of an Oliver Velez who talks about a "narrow state" that involves the 20 period simple moving average and the 200 period simple moving average, but the examples he posts are "subjective" and he doesn't define it precisely. It feels like "you know it when you see it". What you've provided so far is also subjective, so need some objective criteria in what you mean by narrow (error, deviation, percentile, etc.), in-between (above, below, etc.), tightening (what exactly is tightening?) etc. that can be relayed to ThinkOrSwim.

iGhHTDJ.png


I was actually watching those exact videos and was wondering how one could scan for something like this
 
Last edited:
I believe the point of finding stocks where the sma20 and sma200 are close together is that when a move is initiated from this state, they tend to be more explosive with a bigger up or down move than usual. If also the price of the last 30 minutes of previous day (high price and low price) are also close it makes it Ideal an similar situation as an opening day breakout except this starts 30 mins from previous day.
The way it works is if the price opens above the trap zone created by ( 1. high of last 30 mins, 2. low of last 30mins, 3. 20sma & 4. 200sma ) then is buying bias if price is within the trap zone do nothing and if price is below the trap zone is a selling bias.
 
I believe the point of finding stocks where the sma20 and sma200 are close together is that when a move is initiated from this state, they tend to be more explosive with a bigger up or down move than usual. If also the price of the last 30 minutes of previous day (high price and low price) are also close it makes it Ideal an similar situation as an opening day breakout except this starts 30 mins from previous day.
The way it works is if the price opens above the trap zone created by ( 1. high of last 30 mins, 2. low of last 30mins, 3. 20sma & 4. 200sma ) then is buying bias if price is within the trap zone do nothing and if price is below the trap zone is a selling bias.
Ah gotcha, interesting strategy. I might look into this more
 
Don't know if this will help but been thinking about it a lot, what if the scan is on the daily (since you said it would change in different TF) and the parameters would be the high and low price of the previous day last 30 min, where we can input the price value of the difference between the high and low that we would like to see (like show only if difference between high and low is .75, depending on the price range were looking for) and then is only true if the 20sma and the 200sma are within that range and then the study would plot it in the chart like a opening range breakout

I can't script to save my life just trying to help!
 
Don't know if this will help but been thinking about it a lot, what if the scan is on the daily (since you said it would change in different TF) and the parameters would be the high and low price of the previous day last 30 min, where we can input the price value of the difference between the high and low that we would like to see (like show only if difference between high and low is .75, depending on the price range were looking for) and then is only true if the 20sma and the 200sma are within that range and then the study would plot it in the chart like a opening range breakout

I can't script to save my life just trying to help!
That is possible. My SecondsTillTime() programming isn't that get ATM, i might try to do this in future as practice
 
I was actually watching those exact videos and was wondering how one could scan for something like this

Because Mr. Velez doesn't define the narrow state exactly, here's a scan for stocks where the 20 Period Simple Moving Average and 200 period Simple Moving Average are within 5% deviations of each other, based on a comment by EnclaveDCLXVI in the Youtube comment section:

"There seems to only be one missing ingredient; the scan. Too many results for a 5% max deviation between the moving averages. There's more needed to this set-up than is recorded... the scan.

Note that the charts in his examples have extended-hours OFF.

SCAN
Code:
# scan for 20 SMA is within 5% deviation of the 200 SMA
# by: tradecombine
# References:
# https://usethinkscript.com/threads/scan-for-narrow-range-candle-sticks.9764
# https://www.youtube.com/watch?v=Lqbbxxp6Xvc
# Note: 2 minute time frame, extended hours = OFF

input shortLength = 20;
input longLength = 200;
input deviations = 0.05; #5 %
def SMA20 = Average(close, shortLength);
def SMA200 = Average(close, longLength);

def stdDeviation = StDevAll(SMA200);

def UpperLine = SMA200 + deviations * stdDeviation;
def LowerLine = SMA200 - deviations * stdDeviation;

plot scan = SMA20 <= UpperLine && SMA20 >= LowerLine;

UPPER STUDY
Code:
# upper study for 20 SMA is within 5% deviation of the 200 SMA
# by: tradecombine
# References:
# https://usethinkscript.com/threads/scan-for-narrow-range-candle-sticks.9764
# https://www.youtube.com/watch?v=Lqbbxxp6Xvc
# 2 minute chart
# turn off extended hours


input shortLength = 20;
input longLength = 200;
input deviations = 0.05; #5 %
plot SMA20 = Average(close, shortLength);
plot SMA200 = Average(close, longLength);
SMA20.SetDefaultColor(Color.CYAN);
SMA200.SetDefaultColor(Color.Red);

def stdDeviation = StDevAll(SMA200);

plot UpperLine = SMA200 + deviations * stdDeviation;
plot LowerLine = SMA200 - deviations * stdDeviation;
UpperLine.SetDefaultColor(Color.White);
LowerLine.SetDefaultColor(Color.White);

I ran the scan just now on the S&P 500 (evening of 2/10/2022), and returned one stock: KMB


nTmc0eA.png


In the image,
RED LINE = 200 sma
WHITE LINES = 5% deviation of the 200 SMA.
CYAN LINE = 20 SMA
 
Solution
Thread starter Similar threads Forum Replies Date
A Engulfing Candle Scan Questions 0
D Power X Scan Questions 0
A Bull/Bear 180 Scan Questions 0
T 3 day low and 8 day low scan Questions 0
rvaidyamath TTM Squeeze scan not working Questions 2

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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