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.

syntax for gap in last 40 days

Please help for syntax for " no gap greater than 20% in last 40 days"

Best Answers

  • markdmarkd mod
    edited September 2 Answer ✓
    This the criterion Stockcharts uses to define a gap.


    AND [Daily Low > Yesterday's Daily High * 1.026]

    In other words, today's low is above yesterday's high by more than 2.6% of yesterday's high.

    So, if yesterday's high was 10, today's low should be above 10.26 (10 x 1.026). 1.026 seems like an arbitrary number, but nothing wrong with it either.

    So you want gaps (if any) to be less than 20% - I assume you mean less than 20% of yesterday's high. Let's also assume you mean gaps up.

    So for the first day (today - the day you run the scan), that would be

    and [low < 1 day ago high * 1.2]

    So if yesterday's high was 10, you want today's low below 12 (10 x 1.2 = 12)

    For the prior day it would be

    and [1 day ago low < 2 days ago high * 1.2]

    and the next day

    and [2 days ago low < 3 days ago high * 1.2]

    and so on for forty days.

    I don't think there is any short cut for writing out all 40 days.

    Notice also, this scan will pick up falling stocks. If you don't want that, you need to include something at the top to exclude them. Maybe close above a rising moving average. So your scan would start

    [group is sp500] // or your choice of universe to scan - a group or a favorites list

    and [ close > sma(20, close)] // close above its average
    and [sma(20, close) > 20 days ago sma(20,close)] // average is rising






  • RnovaRnova
    Answer ✓
    Thanks Markd for your help. Thanks also for your tip on how to exclude downtrending stocks.
Sign In or Register to comment.