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.

how to write a syntax for this?

Hi I am new to this forum. I was using "open is more than 3% below high 1 day ago" on stockfetcher to scan certain stocks. Can anyone please help me convert this to a Syntax for Stockcharts? I tried a few times but did not get any good results. Thanks.


  • Options
    [group is sp500] // or whatever you want

    and [open < 1 day ago high * .97]

    I'm guessing you just needed to think of "3% below yesterday's high" in a different way - as 97 per cent of yesterday's high, which is exactly the same thing.

    But if you were having trouble with the scan language, here's a link to some good "example" scans that you can cut and paste from and/or edit:

    Also look at the resources for scanning under "Chart School". It's a bit of a slog to get through, but worth it if you plan to write more than a few scans.
  • Options
    This is so helpful! Thanks!!

    May I ask one more question? How to write something for "average day range(2) 1 day ago is more than 20%".

    I looked into the link you gave but couldn't find anything.
  • Options
    I'm not sure what you are asking. What is more than 20 per cent of what?
  • Options
    edited November 2016
    Sorry for the confusion. Here is what I wanted "average day range(2) 1 day ago is more than 20% higher above today's average day range(1)". Thanks!
  • Options
    So, does that mean today's range is less than 80 per cent of the average range of the past two days?
  • Options
    Yes. I tried [[2 day ago range + 1 day ago range]/2 > today's range * 1.2] and it seems to work. Thanks for the hint!
  • Options
    markdmarkd mod
    edited November 2016
    The reciprocal of .8 is actually 1.25, but 1.2 is close enough.

    The way you wrote it is perfectly fine (well done!). Another variation (not better or worse) would be:

    and [ range < 1 day ago sma(2,range)* .8 ]

    The function sma( ) calculates a simple moving average (every item has equal weight in the average). It take two parameters, a number and an element to be averaged. So you can average the high, the low, the close, the open, the range, or even an indicator.

    You might like to add this line to the very end of your scan (it must be the last line, or you get an error):

    rank by SCTR

    Save the results list in that order and then see where your best chances are. You can research this by running the scan for a past date - say a month ago, and see what happened.

    It looks like you may be picking up on an idea that has been around for a while - narrowing range precedes a price reversal. Here is a link to a Chart School page on Tony Crabel's NR7 (narrowest range in seven days) technique, including scan code you can copy and paste:

  • Options
    Thanks for the very helpful answers! I will study in more detail following your link. So knowledgeble Man!
Sign In or Register to comment.