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

scan syntax

Hello to Everyone,

Is there a StockCharts scan syntax that pinpoints stocks where an indicator line has just crossed over its' signal line such as at the moment when the +DI line crosses over the -DI line or at the moment when an EMA(9) crosses over the EMA(15) line? Of course, I have used the "x" crossover but the crossovers have already occurred two to three days before.

I have searched on StockCharts with no results. Any suggestions are greatly appreciated!

Best,
John Train

Comments

  • Options
    markdmarkd mod
    edited April 24
    The "x" operator should select only those symbols where the value for the current bar is above the reference value, and the value for the prior bar was below the reference value - e.g. yesterday, ema 9 was below the ema 15, and today it is above the ema 15.

    Of course, both bars are moving - changing value - so that may create the appearance of more bars having gone by.

    If you haven't done so already, try using the inspect bar to line up the indicator values with the price bars. Or, use the start/end end feature for the chart's duration and advance it day by day to see exactly when the crossover occurs.

    If none of those solve the problem, make sure you are running the scan as of today, and not a past date. If you run the scan for a past date, you still get the chart as of today, not the past date- e.g. if you ran the scan for the crossover as of two days ago, it will be three days ago on the chart that gets displayed.
  • Options
    Hi Mark,

    None of the above provided any stock chart at the moment where, for example, the ema(9) just crosses the ema(15) or at the moment when the +DI line crosses the -DI line. Am I correct to conclude there is no syntax available to produce exact moment indicator crossover's?

    John Train
  • Options
    Mark,

    When I use a stock chart with a daily time period and a 6 month range, the x shows the ema(9) crossover of the ema(15) as just occurring but when I use the 60 minute period with a 1 month range, the ema(9) crossover of the ema(15) displays the crossover happening earlier in the day or days before. Why does the x syntax appear to work with the daily time period and 6 month range and not the shorter 60 minute period and 1 month range? Is there syntax to compensate for this difference in scan result?

    John Train
  • Options
    My most recent answer appears to be missing.

    Basically, I said, the scan engine compares closing data. On a chart, that data would be represented by dots coincident with the bar in question. For instance, on the current bar ema 9 might 9.75. On the previous bar let's say it was 9.25.

    If instead of using dots on the chart you use lines. the lines would connect the dots. The lines make it look like the ema had a series of continuous values between 9.25 and 9.75. But it didn't. The line just makes it look that way.

    Same for the ema 15. In reality, there are only two dots, one for current bar, one for the previous bar. When you draw a line between them it represents "theoretical" values, not real values. So the "moment" of the crossover, represented on the chart by the intersection of two lines, never actually occurred, it is theoretical, too.

    Further, I said, if you run the scan over and over again during the day, you might see the lines cross, but the scan engine considers the last intraday (mid-session) update as the closing value, even though its not. The crossover could go away by the end of the day if the values change before the actual close.



  • Options
    The smallest time frame the scan engine has data for is daily, as far as I know.

    You cannot plot the daily ema crossover on an hourly chart reliably. The data sampling for the calculations is different, so the results will be different.
  • Options
    lmkwinlmkwin ✭✭
    Scanning is only available on daily weekly or monthly time frames for the indicators and prices. Depending on the scan syntax, the EMA's it uses would be based on the Daily EMA or the Weekly EMA or the Monthly EMA.

    The EMA on a 60 minute chart is based on the 60 minute closes. So 9 60 minute periods would make up the EMA9. You can only scan on Daily, Weekly or Monthly so the 60 minute 9 x 15 EMA isn't available for scanning at the moment. It may at some point in the future, but not now.

    So, your original question should have been how to scan for the 9 hour EMA x the 15 hour EMA?

    How to "get around it" would be to try and convert your needs to the available options. 9 hours is a little less than 2 trading days. 15 hours is a little more than 2 trading days. EMA2 x EMA3 ? Or EMA1 (which is the current price) x EMA2 or EMA3? There's no such thing as a EMA1.3 or a EMA2.5 at the moment.


  • Options
    Is there a syntax that scans for an ema(9) that is just near to crossing an ema(15) or a +DI just near to crossing a -DI?
  • Options
    You would have to define what "near" means. Probably some per cent value, rather than points.

    Assuming you mean cross above, you would test that the first value (sma or indicator doing the crossing) is less than the second value (the one to be crossed), and then test that that the first value is greater than some per cent of the second value, e.g. first value less than second value, and first value greater than .98 * second value.
  • Options
    Thanks Mark and LMK for your suggestions, help and guidance. Yes, it would be optimal to give all StockChart users the option to update the scan engine to scan on an hourly timeframe.

    Any other thoughts are appreciated!!

    Mark, what is your suggested syntax for your first value less than the second and first value greater than a percent of the second value using EMA's ?
  • Options
    You can find model syntax examples in the Predefined Scans section.

    Pick a scan, run it, and on the results page click "Edit Scan Criteria" at the top.

    Copy the scan to the scan workbench page and change it around as needed.

    For instance, here is 50/200 crossover (w/o volume conditions)


    AND [Daily SMA(50,Daily Close) > Daily SMA(200,Daily Close)] AND [Yesterday's Daily SMA(50,Daily Close) <= Yesterday's Daily SMA(200,Daily Close)]

    You can edit that to your near crossover like so:

    AND [Daily SMA(50,Daily Close) <b class="Bold">> Daily SMA(200,Daily Close)]
    AND [Yesterday's Daily SMA(50,Daily Close) >= .98 * Yesterday's Daily SMA(200,Daily Close)]

    Now if you run that against the sp500 ( [group is sp500] ) you notice that you get some hits where the short MA has just crossed BELOW the long MA, which is not what you want, but fits the scan criteria.

    If you want to eliminate those, you need to add that the shorter MA is rising, not falling.

    and [sma(50,close) > 10 days ago sma(50,close)

    Note the copied code is "verbose", meaning it includes the default terms, like "Daily", whereas my code does not. If no timeframe is specified, the scan engine assumes you mean "Daily", so you don't have to write it yourself.
  • Options
    Thanks Mark for your reply and may you profit from very good stock or option trades!!!
Sign In or Register to comment.