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.

Scanning for 200-day moving average has been trending higher for X days

I am trying to scan for stocks that are in an uptrend with a volume.

But the specific condition I am looking for us is to check if a stock is above 200-day SMA for more than 14 days in a row.

Below is what I have so far with other conditions I was checking. Stuck on the SMA trend

[type is stock]
and [country = US]
and [Close > 2]
and [weekly volume > 1 week ago sma(10, volume) * 2]
and [weekly close > 1 week ago close]
and [Daily SMA(10,Daily Close) > Yesterdays Daily SMA(10,Daily Close)]
and [Daily SMA(200,Daily Volume) > 1000000]
and [SMA(50) > yesterdays SMA(50)]
// add condition for checking if the stock is higher than SMA(200) for X days in a row

Help, please.

Thanks in advance.


  • Options
    lmkwinlmkwin ✭✭
    There are several ways to do this, here's one to consider.

    There is a function in the Technical Attributes dropdown called DistFromSMA

    it defaults in like this

    and [DistFromSMA(200) > 0]

    If you want to check for 14 days the DistFromSMA is greater than 0, meaning the price is above the SMA, you could use the Min function in conjunction with it. Min is in the Technical Attributes dropdown as well.

    Min defaults in like this

    and [Min(253,close) > 99.9]

    It's saying that the Minimum price close in the last 253 days is > 99.9

    You would change the 253 to 14, and the close to the DistFromSMA(200) to find ones that the min distance from the SMA is greater than 0, or, in other words, the price has been above the SMA for 14 days.

    and [Min(14,DistFromSMA(200)) > 0]

    Note the double )) after the 200. Your number of left ( must equal the number of right ). There is a ( after min and after SMA.

    Tip: If you get a 'failure to parse..." error, it is usually caused by the number of ( not equalling the number of )
  • Options
    Thank you @lmkwin - I'll try now. Appreciate the kindness and willingness to share knowledge.
  • Options
    Thanks again @lmkwin - I am able to get my scan working (doing Weinstein stage2 confirmed stocks list)

    Adding code in case anyone else finds it interesting or if anyone sees issues with the scan itself. I intentionally removed ETFs. A bit of backtesting shows a pretty good list to trade.

    [TYPE = STOCK]
    and [GROUP IS NOT ETF]
    and [COUNTRY IS US]
    and [exchange != PINK]
    and [Daily SMA(200,Daily Volume) > 2000000]
    and [Close > 2]
    and [Close > SMA(50)]
    and [SMA(50) > SMA(150)]
    and [SMA(150) > SMA(200)]
    and [Min(30,DistFromSMA(200)) > 0]
    and [Min(30,DistFromSMA(50)) > 0]
    and [Min(5,DistFromSMA(10)) > 0]
    and [close > yesterdays daily min(253,low) * 1.3]
    and [close > yesterdays daily max(253,high) * .7]
  • Options
    lmkwinlmkwin ✭✭
    edited May 2023
    We are all in this together. This Forum is for sharing and commenting. I learned from others helping me. I try to pass it on, as did you. Thank you for sharing.

    Weinstein Stage analysis is a fascinating study. Remember, he also placed Mansfield Relative Strength awareness into the mix. doesn't have the Mansfield Relative Strength indicator like Stan Weinstein used on his charts. You can view the relative performance on your chart by using the Price or Price Performance indicator on your chart and then using $Symbol:$Spx for the parameter. symbol colon symbol. $Symbol will take the symbol of the chart and put it there in the parameter automatically.

    You can also use $Symbol:$Industry to get the symbol vs its assigned industry or $Industry:$Sector to get the assigned industry vs the assigned sector or $Industry:AAPL assigned industry for the symbol vs AAPL for other examples and comparisons. Use them anyway you want. doesn't have the Mansfield Relative Strength indicator scan either but it does have a PctRelative function that will allow you to scan performance relative to another symbol over a period of time.

    That defaults into the workbench like this

    and [PctRelative(20,$spx) > 0]

    That is saying to find securities in your universe that have a positive return (greater than 0%), relative to the $spx, over the last 20 day period. Mansfield RS is relative to the index but also relative to 0. Much like a MACD.

    Something you may find of interest is to create a scan to look for the Stage 1's. Save those to a list and then create your Stage 2 breakout scan to look at the Stage 1 chartlist.

    There is another site called that has Weinstein screen terms built in to their screening and chart indicator options. It's free to join and use. Like everything in life, it's got positives and negatives. It doesn't have Point and Figure Charts for example. I do run some screens over there from time to time and pull the results into a StockCharts chartlist. It is a decent site, but I still do all of my final research on

  • Options
    Thank you. I am using chartmill as well. I have been manually validating the Mansfield RS through chartbook view for each of the stocks it finds. I'll try the PctRelative as well.

  • Options
    Just an FYI. An Update from for anyone that uses the site. It's got a lot of things going on that aren't available on with many fundamental and technical indicators and rankings and pattern recognition as well as proprietary indicators. I had been using the Free version for a while. Their screener has strengths and weaknesses with one glaring weakness from my perspective but still very good in my opinion.

    "On the first of October 2023 ChartMill will raise subscription prices. While you could consider this bad news, there is mainly good news here: there will be no impact on existing subscriptions! Once you signed up at a certain price, ChartMill guarantees you keep the same price on all renewals as long as the subscription is kept active.

    And there is more good news: as we have not reached the first of October yet, you can still subscribe before the price increment becomes a reality.
    Yes, sign me up please
    ChartMill evolves continuously. In the last years ChartMill became also an excellent fundamental screener, next to the great technical screener it has always been. Because of all these new features, we recently updated our introduction video, which you can watch on youtube:
    Introduction Video Link
    Benefits of a subscription :

    No restrictions on your ChartMill usage.
    Includes all future updates and additional features.
    Never any additional costs.
    No advertisements
    The same price applies to renewals as well. You keep this price as long as your subscription is not canceled."

Sign In or Register to comment.