New Members: Be sure to confirm your email address by clicking on the link that was sent to your email inbox. You will not be able to post messages until you click that link.


Please help me with this coding. I've been going in circles for the past 2 days on the website and cannot find the correct sources that would help me. I've read through dozens of articles and syntax glossary.

I have the following coding on my advance scan:

[type is stock] and [country=US]
and [close > SMA (50,close)]
and [SMA (50,close)>SMA (150,close)]
and [SMA (150,close)>SMA (200,close)]
and [PctDiff(close,min(253,low)) >= 30]
and [PctDiff(close,max(253,high)) <= 25]

I need help with the last two lines.

Basically I need:
-The current stock price is at least 30 percent above its 52-week low
-The current stock price is within at least 25 percent of its 52-week high

This is basically Mark Minervini's Template with the following 8 criteria:

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.

I understand that i need IBD's RS ranking that probably cannot be programmed here so I didn't even try...

Thank you


  • markdmarkd mod
    edited January 2018
    What you have passes syntax and gets results. The ones I reviewed seem to meet the criteria.
    What do you think is wrong with it?

    You do get 999 results, which is the maximum possible (scan engine limits results to 999), but it's a bull market so that's not surprising (country is US includes several thousand stocks). If you want fewer results, you could add requirements for market cap, or closing price, or exchange, or sector or some combination.

    Also, you might check whether Stockcharts SCTR ranking corresponds roughly with the IBD ranking. IBD considers more than technical performance, but there still may be some resemblance.
  • You need to change
    and [PctDiff(close,max(253,high)) <= 25]
    and [PctDiff(close,max(253,high)) <= -25]

    I still get 192 hits, but the charts look reasonable.

  • thank you for the reply. I edited the scan and received significantly less hits. 500+ vs 7. . . hmmm..

    As for the SCTR I set it to 85. Its somewhat close to IBD's RS line. I would say +5/-5 range..

    Thank you very much fellas. I greatly appreciate it! :)
Sign In or Register to comment.