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.

Scan of latest price + ATR criteria

Hi, new member here, trying to figure several things, can't seem to find information relative.

First, can we not scan for stocks based on current price? I know we have the drop-down feature, Last Intraday Update, but how do we write formulas to apply?

Say I want to scan for stocks where one of the criteria is that they are 2% above 200ema. Scan should return previous trading day results when scanned out of hours, and latest results when scanned during trading hours. I currently use:

and [close > ema(200,close) * 1.02]

but this only returns yesterday's results. I also tried

and [ema(200,close) * 1.02]

but this does not bring correct results (some returned are within 2% of 200ema)

Is there a way to solve this one?

Secondly, can't seem to understand, what formula do we write to add criteria, scan for:

price is 1 ATR below 10ema?

Any help would be much appreciated!


  • markdmarkd mod
    edited August 2017
    When you save a scan, it saves whatever you have at that moment in the "Starting 0 days.. " window - either Last Intraday Update or Last Close.

    If you save the scan as Last Intraday update, and run it during market hours, it should give you results as of the most recent update when you run the scan. Note, however, when you bring up a chart in the results list from your scan, the chart you see is created from data as of the most recent update, which may not be the same update your scan used, so the price and the ema may have changed.

    If you save the scan as Last Close and run the scan during market hours, it will return results as of yesterday's close, NOT today's prices. Again, the chart will be as of the most recent update, so it will not be created from the same data that your scan used. If you want to see the chart during market hours as of the last close (yesterday's), you have to use the "select start/end date" option under "Range" in the "Chart Attributes" section of the Chart Workbench.

    If you save the scan as "Last Intraday Update" and run the scan when the market is closed, it should give you same the results as "Last Close". Note, the usual final update is made about 5:30 pm, not 4 pm eastern.

    You can change the "Starting" window setting at any time, so you can run a scan saved as "last close" as "last intraday update", but the next time you use it, it will revert to its saved setting, unless you save your change.

    Over about a decade of use, I have found the scan engine is extremely accurate. That is not the same as saying I have always received the results I expected. Especially as scans get more complex, you may sometimes realize that you got what you asked for, but what you asked for is not what you wanted.
  • markdmarkd mod
    edited August 2017
    To your second question:

    and [close < ema(10, close) - ATR(14)]

    This gets hits with the close below, not at, 1 ATR below the ema.
  • Hi Markd, thank you so much for detailed explanation, very helpful!

    The formula you shared, I understand, will return results only for yesterday's close, while I was looking for this criteria to also be triggered on intraday.

    So I now understand how Last Intraday Update works (thanks!), but for this we still need to come up with right formula, correct?

    How would we translate "and [close < ema(10, close) - ATR(14)]" into something to make it work on intraday as well?

    I got the same issue with "and [close > ema(200,close) * 1.02]". where I want for scan results to return only stocks that are 2% above 200 ema, for intraday data as well.

    This (what formulas to write for intraday examples) still is my biggest mystery question, to remain!

  • There is no need to translate.

    The scan code is the same for running a scan during market hours and after market hours.

    The difference is, if you want to run the scan intraday (while the market is open), you have to set the "start" to 0 days before last intraday update.

    If you do this, and get unexpected results, copy the code here and include one example of an unexpected result (a screen capture of the chart would be great, otherwise a verbal description).

  • That was a missing link, sir! Thank you!! Appreciate your help
  • markdmarkd mod
    edited August 2017
    A note to readers. Another user posted a question about why he got different results after hours from "last close" vs. "last intraday update". Assuming that is what happens, this statement I made above may not be true:

    "If you save the scan as "Last Intraday Update" and run the scan when the market is closed, it should give you same the results as "Last Close". Note, the usual final update is made about 5:30 pm, not 4 pm eastern."

    Now that Stockcharts covers markets around the world, it may be more complicated, especially if your scan is not specific about the exchanges you want to scan.
Sign In or Register to comment.