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.

52 Week High from Previous 5 Days

What is the correct syntax to scan for stocks that have reached a 52 week high from the past 5 days? Thank you for our help...

Best Answer

  • markdmarkd mod
    Answer ✓
    The easy way is:

    and [high > 1 day ago max(251, high)]

    and then use the calendar widget on the advanced scan page (above the scan window) to adjust the date of your scan to five days ago.

    Note: if you want to scan for the close above the 52 week high, then it's

    and [close > 1 day ago max(251, high)]

    You can verify your results by adding the Price Channel overlay to your chart with 251 for a parameter (number of trading days in a year).

    If you want a close above the highest close, then its

    and [close > 1 day ago max(251, close)]

    You can't verify those results visually because the price channel overlay uses highs and lows, not closes. But the result will usually be very similar to the other variations.

    If you don't want to use the calendar to adjust the scan date, it would be


    and [5 days ago close > 6 days ago max(251, close)]

Answers

  • Thank you markd. I was using the "max" parameters wrong. Thanks again...
  • Great. Cool avatar!
  • Hello markd...I backed tested your each of your comments above from my list that I update each day...worked perfectly!!! Thank you for your help.

    I went to school at Michigan State University during the era when the football program was not so good. I'm proud to raise the "flag" that I've hidden in the closet for many years...Go Spartans
  • markd
    Sorry to hi jack the post but if i am looking to scan a 52 week high from the last 15 days, it would be
    [15 days ago close > 16 days ago max(251, close)]

    thanks
  • Hi @morganj71 ,

    All of these scan versions pick up the exact day of crossing - so your scan would get you a crossing exactly 15 days ago, not "within" the last fifteen days.

    A scan to pick up all crossings "within" a period of time would be really complex and in a rising market would get more hits than you could look at easily (unless you limit the universe pretty narrowly). So I think it's better to write it for "today", and then use the calendar tool to select past dates.
  • Hello markd and morganj71...

    I've been working on the syntax that markd originally sent to me. I combined the request from morganj71 to scan a 52 week high WITHIN the last 15 days. Here is the modified version to the syntax (note: the use of BRACKETS to group clauses of "OR").

    In my modify version I was interested in finding stocks whose close are greater than the 52 week high WITHIN the past 5 days. Again the key to this is to have brackets that group clauses of "OR".

    AND [[Daily Close > Yesterday's Daily MAX(251,Daily High)]
    OR [Yesterday's Daily Close > 2 days ago Daily MAX(251,Daily High)]
    OR [2 days ago Daily Close > 3 days ago Daily MAX(251,Daily High)]
    OR [3 days ago Daily Close > 4 days ago Daily MAX(251,Daily High)]
    OR [4 days ago Daily Close > 5 days ago Daily MAX(251,Daily High)]]

    # This scan looks to find 52-Week daily close greater that 52 week high from within the past 5 days.
    # Note the use of brackets to close groups of clauses using "OR"

    I hope this helps...Happy Trading!!!
Sign In or Register to comment.