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.

May I ask the advice of someone who would be willing to coorect my scan?

[FAVORITES LIST IS 1] OR [FAVORITES LIST IS 2] OR [FAVORITES LIST IS 3] OR [FAVORITES LIST IS 4] AND [ [MACD LINE(12,26,9) > 0.0] AND [YESTERDAY'S MACD LINE(12,26,9) < 0] AND [2 DAYS AGO MACD LINE(12,26,9) < 0] ] OR [ [MACD LINE(12,26,9) < 0.0] AND [YESTERDAY'S MACD LINE(12,26,9) > 0] AND [2 DAYS AGO MACD LINE(12,26,9) > 0] ]

Answers

  • markdmarkd mod
    edited April 2016
    I think this is what you want.

    "OR" statements need an extra pair of brackets around them. You don't have to format your scans as I have done below, but it helps to make things clearer in your own mind if you write out in plain english what you want to do first, then add the scan statements that do what those plain english statements say. Start the plain english lines with //, so the scan engine doesn't try to read them.

    When you get to an "OR" statement, it helps to put those starting and ending brackets in FIRST, then fill them in with the alternate conditions (see your "favorites list" OR statement).

    If you have compound conditions as alternatives within the "OR" statement (as you have here with the multiple MACD conditions) it helps to put a pair of brackets around them, too, for clarity.

    Here's the link to the documentation explaining how to deal with OR statements. About half way down the page is a section called "The 'OR' Issue".

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



    So here's the scan:

    // begin MACD crossover scan

    // define universe from several favorites lists

    // begin universe OR statement

    [

    [FAVORITES LIST IS 1]
    OR [FAVORITES LIST IS 2]
    OR [FAVORITES LIST IS 3]
    OR [FAVORITES LIST IS 4]

    ]

    // end universe or statement


    AND

    // begin MACD conditions OR statement

    [

    // begin first OR condition
    // MACD crossover to the upside

    [

    [MACD LINE(12,26,9) > 0.0]
    AND [YESTERDAY'S MACD LINE(12,26,9) < 0]
    AND [2 DAYS AGO MACD LINE(12,26,9) < 0]

    ]

    // end first OR condition


    OR


    // begin second OR condition
    // MACD crossover to the down side

    [

    [MACD LINE(12,26,9) < 0.0]
    AND [YESTERDAY'S MACD LINE(12,26,9) > 0]
    AND [2 DAYS AGO MACD LINE(12,26,9) > 0]

    ]

    // end second OR condition


    ]

    // end MACD conditions OR statement

    // end scan

    Finally, I'm a little suspicious of your "favorites list" numbers. (These numbers are assigned by Stockcharts when you create your list, regardless of what name you use.) If the scan does not work as expected, I would comment out those "universe" lists (favorites list is 1, etc.) and re-insert them by selecting each list from the drop down list labeled "Chart Lists" in the Scan Builder section of the Advanced Scan workbench and then formatting them correctly as shown.
Sign In or Register to comment.