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.
Options

Timeframe Continuity Scan Help

Hi everyone, complete newbie to writing scans.

I'm trying to write a simple scan and there is just one, make that 2 things that i can't find.

I want to scan for stocks that are above yesterday's close, this week's open, this month's open and this quarter's open. i got the 3 first right but can't find how to do the quarterly open.

I'd also like to be able to scan for stocks that just met these 4 criteria.

Here's the code

[type = stock] and [country is US]
and [SMA(20,volume) > 500000]
and [close > yesterday's close]
and [open > this week's open]
and [open > this month's open]

TIA

Claude

Comments

  • Options
    markdmarkd mod
    edited June 2019
    As far as I know, there is no "quarterly" time frame modifier in the scan engine, even if your subscription allows quarterly charts.

    https://stockcharts.com/docs/doku.php?id=faqs:what_data_periods_are_supported_by_the_scan_engine

    also about half way down the page here:

    https://stockcharts.com/docs/doku.php?id=scans:advanced_scan_syntax

    If you want with the open on the first day of the most recent quarter, I think you would have to specify how many days ago that was, which of course would change every day. You could get the number of days ago from the calendar tool on the scan workbench page (but run the scan as of today, not the past date).

    If you would be happy with the open approximately three months ago from the current date, instead of the calendar date of the first day of the current quarter, you could use 63 days ago open (assuming an average 21 trading days per month), or you could use something like 3 months ago monthly open.

    If you want to get the first instance of price exceeding some benchmark, use the "x" operator, which means "cross above". It means that yesterday's value was less than some other value, and today's value is greater than that other value (but note that both values could have changed - e.g. close x sma(5, close) - between today and yesterday, both values changed, but yesterday's close was below yesterday's sma, and today's close is above today's sma.

    However, if you use the "x" operator in place of the ">" operator in your scan for every statement, you may get no hits, as it's probably unlikely all four events would happen on the same day.

    If you want to catch the first day that all four are true, you would need a fairly complex "or" statement. Assuming each crossover could occur in any order, you would need a set of alternatives to account for three closes above the corresponding opens, then the fourth close crossing over. Notice the "x" operator moves down in each alternative:


    and
    [ // begin "or" statement

    [ // first alternative

    [ a x b]
    and [c > d]
    and [ e > f]
    and [g > h]
    ]

    or

    [ // second alternative

    [ a > b]
    and [c x d]
    and [ e > f]
    and [g > h]
    ]

    or

    [ // etc.
    ...

    ]

    ] // close "or" statement
  • Options
    cc64cc64
    edited June 2019
    Thank you Mark for the quick reply!

    I will try to wrap my head around the code you sent me ; )

    Best,

    Claude
  • Options
    Looking at it again - you don't need the crossover operator for close > yesterday's close - and it probably wouldn't work. So you would need only three alternatives, starting with the second one above. Skip the first alternative.

    So first alternative set of conditions would be:

    [
    [ a > b] // your first comparison - close vs yday close
    and [c x d] // your second comparison - open vs week's open
    and [ e > f] // open vs month's open
    and [g > h] // open vs quarter's open
    ]

    Then for the second set, everything in the same order, but move the x operator to the next line e x f, then for the third set, g x h.
Sign In or Register to comment.