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.

Having Max() return a date instead of price

I am using this scanner code to find stocks that their 253 days low is less or equal than 1.1 and also the 253 days max is 3.5 equal or more
The problem is I want the 253 days max of 3.5 to be true only forward looking AFTER the 253 days min(253,low) <= 1.1 is found and don't care about maxes before this 1.1 low how to accomplish this?

here is the flawed code I currently use:
[type is stock] and [country = US] and [PctDiff(today's low,max(253,high)) <= -50] and [ max(253,high) >= 3.5 ] and [min(253,low) <= 1.1] and [ volume > 1200000 ]

Best Answer

  • markdmarkd mod
    edited February 2020 Answer ✓
    Well, first of all, the scan engine can return only symbols (and data associated with that symbol, like sector, industry, SCTR, etc.) that match the scan criteria. It cannot return dates or prices or indicator values. The exception to that rule is, the scan engine does return indicator values (along with the other symbol data) if you use a "rank by" statement.

    But, to answer your main question:

    The first option is to run the scan as is and manually weed out the results you don't want. The advantage of this approach is, you will get EVERY symbol that fits your criteria. Other approaches (see below) will miss some symbols that you might want to see.

    A second option is to decide on a cut off date for how long ago the min low happened, then look for max highs since then. So, for instance, the 126 days ago min 126 low is 1.1, and the max(126, high) is 3.5.

    and [126 days ago min(126, low) <= 1.1]
    and [max(126, high) >= 3.5]

    This will miss anything that has a low after 126 days ago, but, everything you get will have a high after the specified low.

    Another option might be to use you scan as is (but without the PctDiff clause - may be too restrictive, I think), and specify a more recent min above a level closer to the max high. For instance,

    and [ min(21, close) > 2.5]

    That ought to get (at least some) stocks that are rising since the min low.

    Obviously, you can modify any of these parameters. At different times, different values will yield better/worse results. But when you are looking for a pattern, it is inevitable you will get some results you don't want, and miss some results you would have wanted. There is a trade off between results and time spent tweaking.
Sign In or Register to comment.