StockFetcher Forums · General Discussion · Need help writing this filter<< >>Post Follow-up
cocoloco
4 posts
msg #151492
Ignore cocoloco
modified
3/27/2020 10:26:43 AM

Hello. I am trying to write a new filter after reading famous investor Mark Miniverni's book, specifically his filter called "Trend Template". Here is what I have written so far, but it seems wrong since I get 233 results, which seems too many, especially in this current market environment.

show me stocks where the close is above the DMA(150) and the DMA(200) and the DMA(150) is above the DMA(200) and the DMA(50) is above the the DMA(150) and the DMA(50) is above the DMA(200) and the DMA(200) is above the DMA(200) 30 days ago and the close is above the DMA(50) and the close is at least 30% above the 52 week low and the close is not more than 25% less than the 52 week high.

Here are the parameters
1. stock price is above 150 and 200 DMA
2. 150 DMA is above the 200 DMA
3. 200 DMA is trending up for at least 30 days
4. 50 DMA is above both the 150 DMA and the 200 DMA
5. stock price is above the 50DMA
6. stock price is at least 30% above the 52 week low
7. stock price is within at least 25% of the 52 week high

Minervini also wants the stock to have a relative strength of at least 70, but he wants to use the Investors Business Daily version of relative strength.
Thanks for any help


xarlor
587 posts
msg #151507
Ignore xarlor
3/27/2020 3:27:16 PM

Here you are.

Fetcher[
close > DMA(150)
close > DMA(200)
DMA(150) > DMA(200)
30-day slope of DMA(200) > 0
DMA(50) > DMA(150)
DMA(50) > DMA(200)
close > DMA(50)

set{52wl,low 52-week low}
close more than 30% above 52wl

set{52wh,high 52-week high}
close less than 25% below 52wh

add column 52wl
add column 52wh
do not draw 30-day slope of DMA(200)
do not draw 52wl
do not draw 52wh
]



cocoloco
4 posts
msg #151615
Ignore cocoloco
4/1/2020 9:54:54 AM

Thank you very much for the help! It was very informative. If I also want to use the regular version of the RSI, how is that written?

Things have changed, language wise, since the early days of stockfetcher it seems, or I just didn't know the easier language. I have been a subscriber for many years, probably since the beginning. Thanks again

xarlor
587 posts
msg #151616
Ignore xarlor
4/1/2020 12:03:38 PM

I don't know how long the "shorthand" language has been on SF. It's been around at least as long as I've been on here back in 2006.

I added the RSI(14) > 70 at the bottom. You didn't specify the RSI period so I used the default.

Fetcher[
close > DMA(150)
close > DMA(200)
DMA(150) > DMA(200)
30-day slope of DMA(200) > 0
DMA(50) > DMA(150)
DMA(50) > DMA(200)
close > DMA(50)

set{52wl,low 52-week low}
close more than 30% above 52wl

set{52wh,high 52-week high}
close less than 25% below 52wh

add column 52wl
add column 52wh
do not draw 30-day slope of DMA(200)
do not draw 52wl
do not draw 52wh

RSI(14) > 70
]



cocoloco
4 posts
msg #151647
Ignore cocoloco
modified
4/2/2020 9:34:34 AM

thanks again. What would be the new code for "average daily volume" for 50 days? I'd like to add that too. 100,000 shares a day?

The RSI wrecks the results, so I can't use it, it seems. The Investors Business daily RSI compares the stock performance to the S&P 500 performance

JoeyVinyl
125 posts
msg #151654
Ignore JoeyVinyl
modified
4/2/2020 10:57:07 AM

@cocoloco

I got this from one of Kevin's filters, I think. You can change the variable name, referenced index, and time frame to whatever you want. I'm not sure if it's what you need, or how to create an RSI from it, but it might help.

set {relstr, relative strength(^SPX,20)}

As for average volume, that's simple.

Average Volume(50) > 100000


cocoloco
4 posts
msg #151674
Ignore cocoloco
modified
4/3/2020 9:44:52 AM

Thanks Joey, what does the 20 signify? Days?

I tried using this(see below), added the column, but it came back with results of the stock compared to the Nasdaq (30) ^IXIC

set{relstr, relative strength(^SPX,20)}
close more than relstr > 1.2
add column relstr

JoeyVinyl
125 posts
msg #151676
Ignore JoeyVinyl
modified
4/3/2020 11:38:36 AM

@cocoloco

I apologize. I should have explained it better.

The Relative Strength indicator basically just compares the ratio of the change in price between two stocks. What it shows you is how the stock you're looking at is doing compared to the index (or stock - it doesn't have to be used with an index). The higher the number, the better. I usually put the result in a column. As I understand it, anything over 1 means the stock is doing better than the index, while anything under 1 means it isn't. It doesn't give you an actual RSI number though. So the 20 that I used just compares that ratio over the last 20 days. Has it been doing better than the S&P 500 over the last 20 days or worse? You can make that number anything from 1 to 100. It's just the number of days you want to compare.

I checked out this article here: https://www.investors.com/how-to-invest/investors-corner/a-stock-breakout-specialty-tool-the-relative-strength-line and it looks like this is what they're talking about rather than getting an actual RSI number. The Relative Strength Rating they talk about is something they create from their own database and can't be recreated here.

So, the "relstr" part of this is just a variable name. It's like variables in programming or coding. You can make it whatever you want as long as it isn't a function name. Here are some lines you can use that should help.

set {relstr, relative strength(^SPX,20)} /* Finding the RS compared to the index */
add column relstr /* creates a column called relstr */
relstr > 0 /* useful for sorting out stocks doing worse than the index */

Hope this helps.


GodIsIAm
1 posts
msg #156825
Ignore GodIsIAm
modified
5/18/2021 2:54:28 AM

That is right. Relative Strength ≠ Relative Strength Index.

Since Relative Strength is a proprietary measure by IBD, there is no way you can apply it here. For more explanation, please visit their website at: https://www.investors.com/research/best-stocks-rising-relative-strength/

Once again, the rules of the Trend Template are as follows:

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.

If you ignore the last point (RS rating), the StockFetcher Code is like this:

Fetcher[Close is above MA(50)
MA(50) is above MA(150)
MA(150) is above MA(200)
MA(200) is increasing for 1 month
Close divided by 260 day low is above 1.3
Close divided by 260 day high is above 0.75
Chart-time is 1 year
Do not draw Close divided by 260 day low
Do not draw Close divided by 260 day high
Apply to symlist(TGLS,AMRK,GOLF,CTS,JELD,AOSL,TECK,ZIM,BAK,BOOT) // Replace with your own watchlist
]



StockFetcher Forums · General Discussion · Need help writing this filter<< >>Post Follow-up

*** Disclaimer *** StockFetcher.com does not endorse or suggest any of the securities which are returned in any of the searches or filters. They are provided purely for informational and research purposes. StockFetcher.com does not recommend particular securities. StockFetcher.com, Vestyl Software, L.L.C. and involved content providers shall not be liable for any errors or delays in the content, or for any actions taken based on the content.


Copyright 2022 - Vestyl Software L.L.C.Terms of Service | License | Questions or comments? Contact Us
EOD Data sources: DDFPlus & CSI Data Quotes delayed during active market hours. Delay times are at least 15 mins for NASDAQ, 20 mins for NYSE and Amex. Delayed intraday data provided by DDFPlus


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.