The trend is your friend

justAnotherTrader

Active member
VIP
VIP Enthusiast
So a lot of us know the old adage the trend is your friend. Furthermore a lot of us would know an uptrend if we seen one, but very few of us know how to scan for an uptrending stock. For us that go long on stocks, we use several different techniques to help us decide whether or not to take a position. Some of these techniques include candlestick patterns, RSI, MACD, Stochastics, and various momentum indicators. One many of us VIPs have been playing around with great levels of success is the Buy the Dip indicator made by @BenTen

None of these techniques are infallible but they tend to work with the highest probability on uptrending stocks. I am going to share a scan with you guranteed to get you some juicy uptrending charts. You guys can do your own research on how to set this up, im just going to leave the framework here. This site has many tutorials and helps thanks to the site creator. Enjoy =)

Fyi, this is not my original idea, but formulated in large part from this site: https://www.marcellagerwerf.com/mark-minervini-trend-template-thinkorswim-scan/
  • Restrict the scan to the S&P 500
  • Average volume > 1 million
Under custom study copy and paste the following:

Code:
close(“period” = AggregationPeriod.DAY) is greater than SimpleMovingAvg(“length” = 150).”SMA”
and
close(“period” = AggregationPeriod.DAY) is greater than SimpleMovingAvg(“length” = 200).”SMA”

and
SimpleMovingAvg(“length” = 150).”SMA” is greater than SimpleMovingAvg(“length” = 200).”SMA”

and
SimpleMovingAvg(“length” = 50).”SMA” is greater than SimpleMovingAvg(“length” = 150).”SMA”
and
SimpleMovingAvg(“length” = 50).”SMA” is greater than SimpleMovingAvg(“length” = 200).”SMA”

and

close(“period” = AggregationPeriod.DAY) is greater than SimpleMovingAvg(“length” = 50).”SMA”

and

close(“period” = AggregationPeriod.DAY) /
Lowest(“data” = CLOSE, “length” = 250)
is greater than 1.3

and

close(“period” = AggregationPeriod.DAY) /
Highest(“data” = close, “length” = 250) > 0.75
 
Last edited by a moderator:

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

@justAnotherTrader

Here is one with entry and exits. I set up mine with RSavg crossses above 0. Works really well.

Code:
##########################################################################################################################
## 1. The current stock price is above both the 150-day (30-week) and the 200-day (40-week) moving average price lines.
## 2. The 150-day moving average is above the 200-day moving average.
## 3. The 200-day moving average line is trending up for at least 1 month (preferably 4?5 months minimum in most cases).
## 4. The 50-day (10-week) moving average is above both the 150-day and 200-day moving averages.
## 5. The current stock price is trading above the 50-day moving average.
## 6. The current stock price is at least 30 percent above its 52-week low. (Many of the best selections will be 100 percent, 300 percent,
## or greater above their 52-week low before they emerge from a solid consolidation period and mount a large scale advance.)
## 7. The current stock price is within at least 25 percent of its 52-week high (the closer to a new high the better).
## 8. The relative strength ranking (as reported in Investor?s Business Daily) is no less than 70, and preferably in the 80s or 90s,
## which will generally be the case with the better selections
## NOTE: Point 8, I have not implemented, because TOS doesn'thave IDB rating.
##
## Reference to conditions above
## 3) (Average(close, length) > Average(close, length)[LookBack])
## 2) and SimpleMovingAvg("length" = 150)."SMA" is greater than SimpleMovingAvg("length" = 200)."SMA"
## 4) and SimpleMovingAvg("length" = 50)."SMA" is greater than SimpleMovingAvg("length" = 150)."SMA"
## 4) and SimpleMovingAvg("length" = 50)."SMA" is greater than SimpleMovingAvg("length" = 200)."SMA"
## 1) and close is greater than SimpleMovingAvg("length" = 200)."SMA"
## 1) and close is greater than SimpleMovingAvg("length" = 150)."SMA"
## 5) and close is greater than SimpleMovingAvg("length" = 50)."SMA"
## 6) and price > x
## 7) and price > y
##########################################################################################################################
declare lower;
## Code Start

input range = 252; #Number of Trading days
input price = close; #Current closing price
input length = 200; #hint length: The length of the moving average
input LookBack = 60; #hint LookBack: The agg-bars back moving average being compared to

def lo = lowest(low,range);
def hi = highest(high,range);

#The current stock price is at least 30 percent above its 52-week low.
def x = 1.3 * lo; #30% above its 52-week low
#def x = 2.0 * lo; #100% above its 52-week low

#The current stock price is within at least 25 percent of its 52-week high
def y = 0.75 * hi; #25% of its 52-week high
#def y = 0.80 * hi; #20% of its 52-week high
#def y = 0.90 * hi; #10% of its 52-week high

# The below reads as SimpleMovingAvg("length" = 200) is greater than SimpleMovingAvg("length" = 200) from 60 agg-bars ago.
#(Average(close, length) > Average(close, length)[LookBack])

input cc=63;
#def C63= simpleMovingAvg(Close, cc);
#def C126= simpleMovingAvg(Close, cc*2);
#def C189= simpleMovingAvg(Close, cc*3);
#def C252= simpleMovingAvg(Close, cc*4);

def C63= inertia(price, cc);
def C126= inertia(price, cc*2);
def C189= inertia(price, cc*3);
def C252= inertia(price, cc*4);

def S1 = (Close - c63)/c63*40;
def S2 = (Close - c126)/c126*20;
def S3 = (Close - c189)/c189*20;
def S4 = (Close - c252)/c252*20;

plot RS= s1+s2+s3+s4;
input RS_thr = 10;

#plot scan = if ((Average(close, length) > Average(close, length)[LookBack])
#and SimpleMovingAvg("length" = 150)."SMA" is greater than SimpleMovingAvg("length" = 200)."SMA"
#and SimpleMovingAvg("length" = 50)."SMA" is greater than SimpleMovingAvg("length" = 150)."SMA"
#and SimpleMovingAvg("length" = 50)."SMA" is greater than SimpleMovingAvg("length" = 200)."SMA"
#and close is greater than SimpleMovingAvg("length" = 200)."SMA"
#and close is greater than SimpleMovingAvg("length" = 150)."SMA"
#and close is greater than SimpleMovingAvg("length" = 50)."SMA"
#and price >= x
#and price >= y
#and RS>=RS_thr
#,1,0);

input RSlength = 20;
plot RSavg = simpleMovingAvg(RS,RSlength);

plot enter = if RS - RSavg[1] >0 then 10 else -10;
plot zeroline = 0;

an on top of that I use these two along with the above scanner

Code:
#Must be over 40
#WLC_RS6mo
#RS_Rank - 8/28/2019 Developed by GHorschman  ([email protected])
#######################################################################
# This is a custom quote to compute the Relative Strength percentile.
# It is calculated the same way that IV_Percentile is computed.  Just
# change the length to specify the time frame of interest.  The
# background color is tied to the following ranges:
#
#    RS_Rank > 80       -- Green
#    80 <= RS_Rank < 60 -- Light Green
#    60 <= RS_Rank < 40 -- Gray
#    40 <= RS_Rank < 20 -- Light Red
#    RS_Rank <= 20      -- Dark Red
######################################################################

# Set length to period of interest.

#  1 Wk – 5 trading days
#  1 Mos – 21 Days
#  3 Mos – 63 Days
#  6 Mos – 126 Days
#  12 Mos – 252 Days

def length = 7;

#def RS = if IsNan(relativeStrength("SPY")) then 0 else relativeStrength("SPX") ;
def RS = RelativeStrength ("SPY");
def RSLow = Lowest(RS, length);
def RSHigh = Highest(RS, length);
def RSRank = Round(100 * (RS - RSLow) / (RSHigh - RSLow), 0);




plot line = Average(RSRank);

#plot baseline = 40;

AddLabel(yes, "40Week " + Average(RSRank), if Average(RSRank)> Average(RSRank) from 1 bars ago then Color.GREEN else Color.RED);

#End Code

Code:
#Must be over 20
#WLC_RS6mo
#RS_Rank - 8/28/2019 Developed by GHorschman  ([email protected])
#######################################################################
# This is a custom quote to compute the Relative Strength percentile.
# It is calculated the same way that IV_Percentile is computed.  Just
# change the length to specify the time frame of interest.  The
# background color is tied to the following ranges:
#
#    RS_Rank > 80       -- Green
#    80 <= RS_Rank < 60 -- Light Green
#    60 <= RS_Rank < 40 -- Gray
#    40 <= RS_Rank < 20 -- Light Red
#    RS_Rank <= 20      -- Dark Red
######################################################################

# Set length to period of interest.

#  1 Wk – 5 trading days
#  1 Mos – 21 Days
#  3 Mos – 63 Days
#  6 Mos – 126 Days
#  12 Mos – 252 Days

def length = 21;

#def RS = if IsNan(relativeStrength("SPY")) then 0 else relativeStrength("SPX") ;
def RS = RelativeStrength ("SPY");
def RSLow = Lowest(RS, length);
def RSHigh = Highest(RS, length);
def RSRank = Round(100 * (RS - RSLow) / (RSHigh - RSLow), 0);




plot line = Average(RSRank);

#plot baseline = 20;

AddLabel(yes, "20Month " + Average(RSRank), if Average(RSRank)> Average(RSRank) from 1 bars ago then Color.GREEN else Color.RED);


#End Code
 
Last edited by a moderator:
Hi @Art
I'm using above scanner and I'm finding it very useful, I'm reviewing your codes and wonder how do I use it...specially last two codes for upper/chart view. Not sure if I'm doing I'm something wrong but I'm not sure what I'm expected to see on charts with these codes? Do I need to use with specific time frame?
Any screenshot of the view for these codes or could you elaborate a bit more how do I use it for entry and exit.
Thank you
Izet
 
Hi @Izet99 , I use 4hr and daily charts. The last two codes I use in my scanner as conditions that must be met. I set one of them above 40 and the other one above 20 as stated in the code on a 4hr chart.
 
I ran into this scanner to try it out but ran into an error, I can't save it it says: Exactly one plot expected, not sure where the double plot is or what needs to be #..Anyone know what's missing?
 
Last edited:
I ran into this scanner to try it out but ran into an error, I can't save it it says: Exactly one plot expected. Anyone know what's missing?
There are no errors when the code from the TOP POST is stuffed into the Scan Hacker (on a daily aggregation).
It should look like this:
77zvF4c.png


If you are attempting to use @Art's two scanners found here:
https://usethinkscript.com/threads/the-trend-is-your-friend.3615/#post-39833
They must first be saved as studies; then select those studies in the Scan Hacker under add study.
The filters are explained in the top line of each scanner and then again here:
https://usethinkscript.com/threads/the-trend-is-your-friend.3615/#post-40306
 
Last edited:
So a lot of us know the old adage the trend is your friend. Furthermore a lot of us would know an uptrend if we seen one, but very few of us know how to scan for an uptrending stock. For us that go long on stocks, we use several different techniques to help us decide whether or not to take a position. Some of these techniques include candlestick patterns, RSI, MACD, Stochastics, and various momentum indicators. One many of us VIPs have been playing around with great levels of success is the Buy the Dip indicator made by @BenTen

None of these techniques are infallible but they tend to work with the highest probability on uptrending stocks. I am going to share a scan with you guranteed to get you some juicy uptrending charts. You guys can do your own research on how to set this up, im just going to leave the framework here. This site has many tutorials and helps thanks to the site creator. Enjoy =)

Fyi, this is not my original idea, but formulated in large part from this site: https://www.marcellagerwerf.com/mark-minervini-trend-template-thinkorswim-scan/
  • Restrict the scan to the S&P 500
  • Average volume > 1 million
Under custom study copy and paste the following:

Code:
close(“period” = AggregationPeriod.DAY) is greater than SimpleMovingAvg(“length” = 150).”SMA”
and
close(“period” = AggregationPeriod.DAY) is greater than SimpleMovingAvg(“length” = 200).”SMA”

and
SimpleMovingAvg(“length” = 150).”SMA” is greater than SimpleMovingAvg(“length” = 200).”SMA”

and
SimpleMovingAvg(“length” = 50).”SMA” is greater than SimpleMovingAvg(“length” = 150).”SMA”
and
SimpleMovingAvg(“length” = 50).”SMA” is greater than SimpleMovingAvg(“length” = 200).”SMA”

and

close(“period” = AggregationPeriod.DAY) is greater than SimpleMovingAvg(“length” = 50).”SMA”

and

close(“period” = AggregationPeriod.DAY) /
Lowest(“data” = CLOSE, “length” = 250)
is greater than 1.3

and

close(“period” = AggregationPeriod.DAY) /
Highest(“data” = close, “length” = 250) > 0.75
Hello everyone,
I am learning scanner in TOS, i could get nearer to this script but the last 2 things i am unable to find where to enter those value (apart from "thinkscript editor") is there some thing i am missing, or is that value should be enter in the thnikscript only, please suggest. But after even enter those value i didn't get any stocks listed in search today. guide me if i need to change in the code.

@MerryDay, @BenTen or some one please help to get this scanner correctly.

CDLrxqZ.png
 
Last edited:

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
426 Online
Create Post

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