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 setup questions...

Hi All, I am testing the stock charts scanner to see if it fits my needs. Couple of things I am having trouble with getting the syntax correct..
1. One parameter I want, amongst many others, is a rising 200 Dma. I can't seem to find the right syntax to make this requirement show through on my scans. Any help would be greatly appreciated!
2. I also want the current price to be within 10% of 52-week highs. Again, I need the correct syntax. Everything I am trying is not working.

I look forward to learning from you Stockcharts scanning experts!


  • markdmarkd mod
    edited November 18
    You need to compare the MA today to the same MA some number of bars before today, and today's value should be greater than the previous value.

    The value of the sma today is

    sma(200, close)

    The value of the past bar could be something like

    21 days ago sma(200, close) // or some other value, 10 days ago, 50 days ago

    And you would compare them using a comparison operator, in this case greater than, which is ">". And you need to put the whole comparison statement between a pair of brackets [ ]. Look at some sample scans for examples.

    Scan documentation is here:

    For "within 10% of 52 week high", you need to compare the current price to fractional multiples of the 52 week high.

    The 52 week high is

    weekly max(52, weekly close) // or, you could use high instead of close.

    or, if you want to keep everything in the daily time frame (good idea):

    max(251, close) // 251 trading days in most years, sometimes 252 or 253 depending where holidays land.

    Fractions, or per cents, of a value are expressed with decimals. So, "within 10%" is between .9 and 1.1 times the max value(100% is 1.0, ten per cent is .1, so 1.0 - .1 = .9 and 1.0 + .1 = 1.1. So, you want the price (meaning today's close) to be greater than

    max(251,close) * .9

    and less than

    max(251,close) * 1.1

    That requires TWO statements, one for less than, one for greater than.

    If you get stuck, post what you have.

  • Great info! I will give it a try and get back to you. Many Thanks!
  • All that great information worked! Thanks again!
  • Just a short comment: you like others getting started with scanning had a question regarding syntax - but really, the obstacle isn't syntax (which is really just punctuation and order of terms), but how to think about what you want.

    Many people think scanning is hard because it's programming and they don't know how to program. But it's not the syntax that is really so challenging. You can easily pick up most of it just by looking at the examples.

    Most of the time, what you really need is to find a way to restate your requirements using the terms and operators available in the scan engine -many of which most people have seen before. For instance, above and below (this one is obvious) really mean greater than or less than. So if you say you want to scan for the current price above the MA, then you want a "close" greater than ">" the MA "sma(200,close)".

    Something like "rising" takes a little more thought. There is no "rising operator", so you have to think of something that is true about a stock (or an MA, or an indicator) that is rising. In other words, you have to come up with a definition by using the scan engines terms and operators. If somebody asked you, what is a summer day, you might say a day between June and September that is long and hot. So if you some one asks you, what does rising mean, you would say something that was lower before and is higher now - and then figure out how to say that with scan terms and operators (today's close > 5 days ago close). Likewise with "within". What does "within" mean - it means greater than one thing and less than another thing.

    So the trick with scanning is to re-think those things we know intuitively and get into the details of what we already know but don't think about anymore. And, of course, getting familiar with the terms and operators available by reviewing a little bit of Chart School every day, or maybe every weekend, until you are pretty familiar with what's available.

Sign In or Register to comment.