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.

20/50 DaY SMA Crossover

I would sincerely appreciate someone assisting me in developing the scanning criteria for the point in time that the 20 day SMA crosses over the 50 day SMA. Its seems straight forward enough, but I cannot quite write the formula correctly. Thank you in advance for your help.


  • Post what you have so far and some one will tweak it.
  • [type = stock] AND [Daily SMA(50,Daily Volume) >9999999]
    and [SMA(20,volume) > 9999999]
    This seems to provide the crossover, however it does not calculate for the most recent day. It present the crossover that has occurred in the recent past. I am attempting to identify stocks that are currently experiencing the crossover. Thank you for your assistance with this.
  • OK. The ones you are getting are just a coincidence, since nothing in your scan mentions moving averages of prices.

    Moving averages of price are usually based on the close. So, for instance, the 20 day sma ("simple" moving average) would be

    sma(20, close)

    SMAs for any other duration would just change the 20 to whatever number.

    There are two ways to catch a crossover, the long way, and the short way.

    The long way is to compare the two smas yesterday (1 day ago) and today. Yesterday, one sma should have been below the other, and today it should be above. So:

    and [1 day ago sma(20, close) < 1 day ago sma(50, close)]
    and [sma(20, close) > sma(50, close)]

    Note that if you have no modifier (like "1 day ago") in front of an indicator or overly (like sma(20, close), an overlay), then the scan engine assumes you mean today's value.

    The short way is to use the cross above operator "x":

    and [sma(20, close) x sma(50,close)]

    When you use the "x" operator, the scan engine knows you what you mean the same thing as the long way.

    The "Instructions" link is a good introduction to working with the scan engine. It explains the various operators, like "x", and how to use the "Scan Builder" section on the advanced scan page, which is real timesaver:

    There are also several links on that page to instructional videos which are helpful.

    Like anything, the scan engine requires a little study before you can really do what you want to do, but it pays off.
  • Sorry, I mauled on of those sentences - should be:

    When you use the "x" operator, the scan engine knows you mean the same thing as the long way.
  • Thank you for your help!
Sign In or Register to comment.