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.

multiple rank per scan

according to https://support.stockcharts.com/doku.php?id=scans:advanced_scan_syntax#rank_by_clauses, only one rank by line per scan, any alternative to multiple rank per scan, eg, rank by roc(14) then pctchange(126, close)

thx in adv

Comments

  • markdmarkd mod
    edited May 2023
    As you note, there is only one ranking possible per scan.

    You can re-rank results on the results page by other column values available on that page. For instance, if you run this scan:

    [group is sp500]
    rank by market cap

    you will get a results list of all the symbols in the sp500 ranked by market cap, and the market cap values will appear in the last column in descending order.

    If you click on the "sector" column, the results will appear by sector alphabetically, and within each sector the symbols will be sorted by market cap.

    So you can rank a list by more than one value. But, there are limitations when you sort by more than one value.

    If you run the scan again, and then sort by "close" on the results page, the list will re-sort from lowest price to highest. But, there will very little or no sub-sorting by market cap because the "close" values are mostly unique (no two closing prices exactly the same to three decimals).

    So in effect, even though you scan-ranked the list, if you re-rank the list by a column with mostly unique values, you negate the scan-ranking order and get the new column ranked order as if you had run the scan for that value (i.e. rank by close).

    So, in your case, even if you could rank a list by MACD and then by PctChange in the same scan, your final result would be a list ranked by PctChange, because both MACD and PctChange are likely to produce mostly unique values You won't get (many, if any) duplicate values as you do with sector ("sector" is a duplicate value because many symbols belong to the same sector). Without duplicate values you won't get sub-sorting.

  • lmkwinlmkwin ✭✭
    Seeing as ROC and PctChange are pretty similar, if that is your desire to multiple rank by, you can use the presets on the Summary page to get close. 1st run a scan using Rank By ROC(14). Then save the results to a chartlist and Preserve sort order.

    scan universe
    rank by roc14

    Your chartlist will now have a 4 digit ranking number in front of the Name of the security. 0010 is #1 and it increments by 10. So 0020 is #2 and so on.

    Summary View Option
    Then view that list in Summary view and change the Period from Intraday to Six Month then click on the % CHG column header to sort in ascending or descending order of six month % change.

    At the bottom of the page there is a button to Number in Sorted Order. If you click this there will be a new 4 digit number added so your Name field will look like this 0110 0010 AAPL ..... So AAPL was the #1 ROC14 and the #11 6 month pctchange for example. Depending on the length of your list this may be a way to get your customized view.

    Performance View Option
    Or you can look at the Performance view of the list. They don't have a column for 14 days but do have a day, 5 days, 1 month, 3 months, 6 months, 1 year, and YTD performance, so could use this view of your initial Rank By ROC14 scan to see the 6 month percentage change instead of the Summary view

    Other thoughts option
    You can also think of what it is that you are trying to achieve with a secondary sort. Is that secondary number important enough to include it in the scan code? If the secondary sort number is really high or really low will that change your interpretation of the chart? I've got a high ROC14 and a low PctChange 126. Should I just exclude those securities by filtering them out in the scan based on that "secondary sort" number? This way I'll know that the secondary sort number is within my guidelines and then can focus on the my primary sort. This assumes that I want to focus on the ROC14. Or is there a combination that I want and can add them together in my rank by.

    Rank by ROC14 + PctChg126

    I can even attempt to weight them

    Rank by ROC14 * 0.65 + PctChg126 * 0.35


Sign In or Register to comment.