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.

accurate scan code ?

Hi Markd and everyone

Can you please check if I wrote the scan code correctly below

1. weekly price crosses above 40-week MA ------>[weekly close x weekly sma(40, weekly close)]
2. Large caps -------------> [market cap > 1000]
3. 50-week MA volume is greater than 1M ------------------> [weekly sma(50,volume) > 1000000]
4. This week's volume is at least one time larger than last week -----> ? ? ?

Basically, I am looking for large cap stocks breaking out on the long-term basis. Any other criteria I shall also use ? Thanks for all your help.

Comments

  • markdmarkd mod
    edited July 2017
    2 Finviz puts large cap at 10B, which is > 10000 (add a zero to yours). But, you could do

    [group is sp500]
    rank by market cap

    and then try

    [group is sp400]
    rank by market cap

    and see where you want to put the cut-off (the results page market cap column is in millions at the decimal point). Remember, market cap varies over time so some stocks near the cut-off will probably drop in and out of your scans.

    4 and [weekly volume > 1 week ago weekly volume * 2]

    You might want to test for the direction of the 40 week sma - or at least note it in your results. A major change of trend may be occurring when the close is the first above a falling sma ( e.g. and [weekly sma(40, weekly close) < 10 weeks ago weekly sma(40, weekly close)]. On the other hand, if the sma is rising (to test for rising sma, change < to > ) and close crosses above, it could be resumption of the trend in place (rising), or, it could be a set up for a short play if it's just a reaction to crossing below the sma in a longer down trend.

  • Hi Markd

    Thanks much for your prompt info. You are so knowledgeable on the market and especially on the scanning area.

    Just to clarify on your last statement:

    On the other hand, if the sma is rising (to test for rising sma, change < to > ) and close crosses above, it could be resumption of the trend in place (rising), or, it could be a set up for a short play if it's just a reaction to crossing below the sma in a longer down trend.

    I thought that if the 40W MA is rising, then the longer time trend is up ? Do you then use monthly chart to check for the trend direction on the much longer time frame ? Thanks again.
  • Well, mathematically, the MA can't change direction unless prices do. So a price trend will change before the MA changes direction. So, when a down trend begins, the MA will still be rising. When a down trend ends, the MA will still be falling. If you follow a strict crossover strategy, you will enter after the up trend has begun, and exit after it has ended. If it's a long trend, you get what's in the middle, but you don't get the first dollar(s) or the last dollar(s).
  • Markd

    I've a few more questions:

    1. In your reply from 7/21, you mentioned that "If you follow a strict crossover strategy, you will enter after the up trend has begun, and exit after it has ended." Here, you are referring to the MAs crossover ? I understood that MAs is a lagging indicator.

    2. I shall test the direction of 40 week sma by inserting

    [[weekly sma(40, weekly close) < 10 weeks ago weekly sma(40, weekly close)] or [weekly sma(40, weekly
    close) > 10 weeks ago weekly sma(40, weekly close)]]

    into the scan formula ?

    3. What is the average 52 week sma of volume for a large cap stock ?

    Thanks much again.
  • 1 You could use either a price crossover or a short MA crossover.

    2 If you test for both, you will get just about everything - for most stocks, the MA is either going up or down. If you want down - this week < 10 weeks ago; if you want up, this week < 10 weeks ago. You can adjust the 10 weeks ago to whatever you like 3, 5, whatever.

    3 if you are asking for a number, I have no idea.
  • I was interested if somebody could help me to code a scan, I am having some difficulty in the coding.

    My criteria is as below

    Price Range (OHLC) +/- 2% of SMA 20 or
    Price Range (OHLC) +/- 2% of SMA 50

    This I need for 4 Hourly candle, Daily Candle & Weekly Candle combined in one scan

  • You can't scan for intraday time frames, like hourly, 5 minutes, etc.

    You can build scans using the "Scan Builders" drop downs on the Advanced scan page. Highlight your choice then click "Insert" to put a default version of your selection in the Scan Criteria window. Then edit the default version for your needs.

    For "Price Range (OHLC)" you can select "range" from the Price, Volume and SCTR drop down.

    For the sma s you can select SMA from the Technical Indicators drop down as many times as necessary.

    Range less than +2 per cent would be less than the sma you choose * 1.02

    Range greater than -2 per cent would be greater than the sma * .98

    BUT: I think what you really mean is that the high is greater than the sma and less than sma*1.02 or the low is less than the sma and greater than the sma *.98.

    To make the "or" statement work, you have to add an extra set of brackets around the "or" alternatives that you want to have evaluated together.

    I think you should try to make it work for one time frame first before combining multiple time frames in one scan.

    A good guide to scanning resources, including syntax, is here:

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

  • Hi Markd
    Thanks for the guidance. I will try to create the syntax. I am a novice but will make an effort. I could need your support again.
    You are doing an excellent contribution in helping people with a passion for trading better. Hats off to you.
  • Thanks for the kind words. If you get stuck, post what you have so far.
  • Hi Mark

    Not reaching anywhere
    Please guide. I sincerely appreciate.

    My main idea is to scan for the stocks when the candle (high or low) reaches 2% on either side of the SMA 20 or the SMA 50.

    type = BAC] AND [country = US] AND [group is SP500 > 400000]

    and [Today's SMA(20,*1.02) >
    Today's SMA(20,*.98)
    Today's SMA(50,*1.02) >
    Today's SMA(50,*.98)]

    Regards

  • Look up SMA in chart school. At the bottom are some suggested scans that will help you with the syntax.

    https://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:moving_averages

    Also check out this page of sample scans. About half way down, see the "price convergence" scans - you can borrow from those to model the syntax for your scan:

    https://stockcharts.com/school/doku.php?id=chart_school:scan_library:gord_greers_scan_bui

    Note each individual condition must have its own pair of brackets and must be preceded by the word "and".

    A condition is a comparison of two values by an operator. In other words, it reads just like a math statement you might have done in high school.

    In your case, for the first condition, the two values are the "high" and the sma(50,close)*1.02. The comparison operator goes between those two values. In this case the comparison operator is "<".


    Put that much together and then try the second condition.

    Also, for now, for your first statement just use [group is sp500], not type=BAC]... etc.



  • Hi markd

    This for a daily candle

    Still making efforts, maybe inching up slowly
    please suggest

    [type = [group is sp500]
    and [1st criteria]
    and [Today's High >= Today's SMA(20,Daily close)*.98]
    and [Today's High <= Today's SMA(20,Daily close)*1.02]
    and [Today's High >= Today's SMA(50,Daily close)*.98]
    and [Today's High <= Today's SMA(50,Daily close)*1.02]
    and [2nd criteria]
    and [Today's Low >= Today's SMA(20,Daily close)*.98]
    and [Today's Low <= Today's SMA(20,Daily close)*1.02]
    and [Today's Low >= Today's SMA(50,Daily close)*.98]
    and [Today's Low <= Today's SMA(50,Daily close)*1.02]

    regards
  • Hi Markd
    There is an error in the syntax please guide.
  • edit the line [type = [group is sp500] to remove "[type ="
    delete the line "and [1st criteria]"
    delete the line "and [2nd criteria]"


    For the rest, your syntax looks correct. So now it's just a logic problem.

    First, get it right for one sma. Then write a separate scan for the other. I think you should run them separately, but if you want to combine I'll show you how after you have them both running right.
  • Thanks markd, it's done for the daily close. Your guidance steered me thru.

    For the next criteria can please show me the way forward for the 4 hourly close.
    When I replace the daily close with 4 hours close there is an error.

    Regards
  • It's not possible to scan for intraday time frames, so "hourly" or "5 minutes" or whatever will give you an error. The scan engine doesn't access intraday data, even though it shows up on the charts, probably because it's always changing.
  • can we get it after the mkt closes . (EOD)
  • No. Not an available option.
Sign In or Register to comment.