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.

Monthly scan

ck_traderck_trader
edited July 2014 in Scanning
Is there anyway to find stock which moved above previous month's high?
Thanks

Answers

  • Here is an initial attempt - not perfect:

    [type = stock]
    and [daily close > 1 day ago daily Max(22,close)]
    # Select Last Intraday Update

    There are 20 or 21 periods in a month. Since today is July 02, 2014, I added 1 (because there has been 1 trading day this month) to 21 to get the 22 for the first parameter of the Max function. This scan will cover last month as well as the periods this month. An assumption I am making is that your question does not specify today. I assume any period this month can be greater than the highest last month. The Max function returns the highest close in the last 22 periods. I believe for technical reasons, 1 day ago has to precede the Max syntax so that today's daily close correctly compares the max starting with yesterday. "1 day ago" can be replaced by "yesterday's".

    So far I see two small problems with this. The Max function is looking at this month too - not exclusively last month. Also, I am only checking today's intraday close, and not all the closes this month. Any other problems? Any other ideas, anyone?
  • markdmarkd ✭✭✭
    edited July 2014
    I think we need to refine what we mean by "last month's high".

    If you mean the high of a calendar month, like the highest high in June, you would have to write a very specific scan that isolates that period, which would vary with each passing day.

    If you mean the high of the last 20 trading days, regardless of how many are in any calendar month, then Kevo's scan is fine (except it would be max(20, high) if you want a close above the highest high, rather than the highest close).

    However, this scan may pick up situations you may not anticipate. I'm guessing you are looking for a breakout, where price has been down for a while and has just broken its previous fairly recent high.

    Unless you also scan for a recent decline, you could pick up an aging rally where each of the last x days has also been a new 20 day high.

    There is more than one solution to that problem. Here's one:

    // close crosses above 20 day channel

    and [close x 1 day ago Upper Price Chan(20)]

    // the 20 day channel has been flat for at least seven (or whatever) days

    and [1 day ago Upper Price Chan(20) = 7 days ago Upper Price Chan(20)]

    Making the channel equal to some past time period implies a decline. Since no price has been higher for x days, they all must have been lower. This doesn't test for how much of a decline there was - it might have been a tight range instead of a real decline (which could still be pretty bullish). If you wanted to test for that, you could add


    // there has been a reasonable decline recently

    and [min(7, Fast Stoch %K(21,0)) < 20]

    You would have to play with all those parameters to see what different kinds of situations they can catch. Maybe change the 21 to 7 or 10, change the 20 to 50, increase or decrease the min 7 to 5 or 10.
  • Thank you Kevo, Markd. I am looking at calender month. So if i run scan today, i want stocks which are crossing june's high.
  • markdmarkd ✭✭✭
    edited July 2014
    So you need to figure out how many trading days there were in June, get the max hi for that many days, then figure out how many days back was June 30 from the date you are running your scan. In other words, follow Kevo's example, but use max hi instead of max close, and change the number of days ago and the max parameter for trading days in June.
  • I am using Kevo's example and it is working for me. Thank you.
Sign In or Register to comment.