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.

Bad Scan Results

Below is a scan that I recently created trying to remember how to use brackets correctly. The scan seems to ignore the MACD Hist(48,104,39) and MACD Hist(48,104,0) criteria / filter. Yesterday it selected UVXY from my Favorites list but I can see that neither of the MACD Histograms met the criteria. I am certain that I have the brackets placed wrong?


[Favorites list is 16] and [[[MACD Hist(48,104,39) > 1 Day ago MACD Hist(48,104,39)] and [[Today's MACD Line(12,26,9) > 0.0] and [Today's MACD Line(12,26,9) > Today's MACD Signal(12,26,9)] and [Today's MACD Line(12,26,9) > Yesterday's MACD Line(12,26,9)]]

or [[Today's MACD Line(12,26,9) > 0.0] and [Today's MACD Line(12,26,9) < Today's MACD Signal(12,26,9)] and [Today's MACD Hist(12,26,9) > Yesterday's MACD Hist(12,26,9)]]

or [[Today's MACD Line(12,26,9) < 0.0] and [Today's MACD Line(12,26,9) < Today's MACD Signal(12,26,9)] and [Today's MACD Line(12,26,9) > Yesterday's MACD Line(12,26,9)]]

or [[Today's MACD Line(12,26,9) < 0.0] and [Today's MACD Line(12,26,9) > Today's MACD Signal(12,26,9)] and [Today's MACD Line(12,26,9) > Yesterday's MACD Line(12,26,9)]]]

or [[MACD Hist(48,104,0) > 1 Day ago MACD Hist(48,104,0)] and [[Today's MACD Line(12,26,9) > 0.0] and [Today's MACD Line(12,26,9) > Today's MACD Signal(12,26,9)] and [Today's MACD Line(12,26,9) > Yesterday's MACD Line(12,26,9)]]

or [[Today's MACD Line(12,26,9) > 0.0] and [Today's MACD Line(12,26,9) < Today's MACD Signal(12,26,9)] and [Today's MACD Hist(12,26,9) > Yesterday's MACD Hist(12,26,9)]]

or [[Today's MACD Line(12,26,9) < 0.0] and [Today's MACD Line(12,26,9) < Today's MACD Signal(12,26,9)] and [Today's MACD Line(12,26,9) > Yesterday's MACD Line(12,26,9)]]

or [[Today's MACD Line(12,26,9) < 0.0] and [Today's MACD Line(12,26,9) > Today's MACD Signal(12,26,9)] and [Today's MACD Line(12,26,9) > Yesterday's MACD Line(12,26,9)]]]]
«1

Comments

  • markdmarkd mod
    edited February 2019
    You have included the Hist 104 conditions in the "or" statement, but also have "or" conditions that don't specify a requirement for Hist 104. So when a Line-Signal condition is true, that symbol will be a hit regardless of the Hist 104 values.

    If you want to specify a Hist 104 condition that is always true, you have to isolate it from the "or" statement.

    [favorites list is 16]

    and [Hist 104 condition]

    and

    [
    [some condition]
    or
    [ next condtion]
    or
    ... etc.
    ]
  • Mark, the proper bracket placement is mind boggling. Below I have tried to emulate / copy a previous bracketing effort that you walked me thru a few months ago. I still don't understand it but I tried to copy it here. Does the below scan eliminate my mistake above?



    [Favorites list is 16] and [[[MACD Hist(48,104,39) > 1 Day ago MACD Hist(48,104,39)] and [[[Today's MACD Line(12,26,9) > 0.0] and [Today's MACD Line(12,26,9) > Today's MACD Signal(12,26,9)] and [Today's MACD Line(12,26,9) > Yesterday's MACD Line(12,26,9)]]

    or [[Today's MACD Line(12,26,9) > 0.0] and [Today's MACD Line(12,26,9) < Today's MACD Signal(12,26,9)] and [Today's MACD Hist(12,26,9) > Yesterday's MACD Hist(12,26,9)]]

    or [[Today's MACD Line(12,26,9) < 0.0] and [Today's MACD Line(12,26,9) < Today's MACD Signal(12,26,9)] and [Today's MACD Line(12,26,9) > Yesterday's MACD Line(12,26,9)]]

    or [[Today's MACD Line(12,26,9) < 0.0] and [Today's MACD Line(12,26,9) > Today's MACD Signal(12,26,9)] and [Today's MACD Line(12,26,9) > Yesterday's MACD Line(12,26,9)]]]]

    or [[MACD Hist(48,104,0) > 1 Day ago MACD Hist(48,104,0)] and [[[Today's MACD Line(12,26,9) > 0.0] and [Today's MACD Line(12,26,9) > Today's MACD Signal(12,26,9)] and [Today's MACD Line(12,26,9) > Yesterday's MACD Line(12,26,9)]]

    or [[Today's MACD Line(12,26,9) > 0.0] and [Today's MACD Line(12,26,9) < Today's MACD Signal(12,26,9)] and [Today's MACD Hist(12,26,9) > Yesterday's MACD Hist(12,26,9)]]

    or [[Today's MACD Line(12,26,9) < 0.0] and [Today's MACD Line(12,26,9) < Today's MACD Signal(12,26,9)] and [Today's MACD Line(12,26,9) > Yesterday's MACD Line(12,26,9)]]

    or [[Today's MACD Line(12,26,9) < 0.0] and [Today's MACD Line(12,26,9) > Today's MACD Signal(12,26,9)] and [Today's MACD Line(12,26,9) > Yesterday's MACD Line(12,26,9)]]]]]
  • I'm sorry, this scan is much too dense for me to untangle. I don't see the difference between this and the previous entry. I think it would be much more efficient to run separate scans for each condition, but that's just the way my head works.
  • Thanks again.
  • markdmarkd mod
    edited February 2019
    I would suggest you document what each collection of conditions is testing for - in other words, write the test in common english - such as "// MACD Line rising above zero". Also, it would be very helpful for clarity if you wrote ONE "and" condition on each line. It would also make it much easier to track the brackets.

    It looks like you are testing for every possible state of MACD Line and Signal, but maybe not. Also, it looks like you could use the crossover ( "x" ) operator, which would make things simpler to read.
  • Thanks Mark. My second iteration above works well. I finally realized that I had enough available characters to include each of the two MACD 104 with each daily macd condition. I have two primary conditions....(48,104,36) and ....(48.104,0) and I have four secondary daily conditions that go with each of the two primary conditions. You figured all of this out for me a few months ago when I was trying to compress a scan where I had used up all of the available characters that the scan offered. I don't know why my little pea brain has such a hard time understanding how to use brackets correctly but it does. I still don't know why moving the brackets around in my second attempt above works but it does. Thank you
  • Mark, assuming that you'll see this, I wanted to tell you that I am getting close to having all of my scans just about as good as I feel they can get and it has been because of your help. Just stopping in this morning to tell you thanks again for your help. I may stop by again one day but for now, I think that I am good to go.

    Thanks,

    David
  • Thanks for the kind words. I hope it works out for you.
  • GM Mark. It is working very well thanks to you. I do have another question that may be a little difficult to describe this way but here goes nuttin. I am trying to build another scan and when I get the scan results there is a number provided under a heading...SCTR. I had always assumed that number was the same number that I would find if I added the SCTR line to a chart but it's not, they are different. I'd like to add the SCTR number ( the one you would see in scan results ) to my scan as a filter. In other words, I'd like to ask the scan not to consider anything with a SCTR ( the same SCTR as shown in scan results ) < 45 but I can't figure out how to ask my scan for it?
  • I find that the SCTR values from the scan results and the charts DO match.

    Try this scan:

    [group is TechnologySector]
    and [SCTR >90]
    rank by sctr

    Then down load the CSV file. Then save the results list to a new list, or replace an existing list, and check off the box to keep the sort order. Add the SCTR Line indicator to the charts, then compare the values to the CSV file. They will be the same.

    Note that if you run the scan for a PAST date, the results page displays data for the CURRENT date. So, if you run a scan for a date a month ago (e.g. 4/17), and you ask for [SCTR > 45], you may get SCTR values on the results page which are LESS than 45 because the SCTR value has changed between the scan date 4/17 a month ago and the current date 5/17. So, to check the scan results, you would have to edit the chart start/end date so the chart ends on the scan date (4/17), apply to all, then view the SCTR Line indicator values.
  • Mark, thanks again. I was running for past dates.
  • For a while, it sure looked like a great filter tho.
  • I think the scan results are still good. In other words, if you back date a scan, the symbols returned will meet the condition you set for SCTR, even if the results page SCTR values don't.

    So, if you ask for SCTR > 45 and back date the scan for a month ago, the symbols you get had SCTRs greater than 45 on that date.
  • I understand. However, I am looking for a filter that might limit the number of losers for this new scan. So, while back testing today, it looked like the SCTR would be a great filter. Now that I understand what the scan results are giving me, it's not so good as a filter. Darn it
  • Mark, do you know if there is a way to write into a scan that MACD for SPX has to be met before any of the other criteria are even considered? As an example....MACD Fline for SPX has to be rising before the scan will pick anything.
  • Also, I'd like to try my scans on a lower time frame, maybe an hourly if confirmed by daily or something like that. Since, SC does not provide for lower time frame scanning, do you know of a service that might be set up for it? TC2000 might be one but I am not sure yet
  • markdmarkd mod
    edited May 2019
    Well, if the SPX condition is binary - e.g, MACD can be above zero or below zero - you might be able to use an "or" statement.

    For instance, if you want symbols ONLY if the SPX MACD is above zero, test for MACD for SPX below zero. If it is true, the scan should return only SPX. If it is false, it should return symbols for the other "or" conditions, if they are true. So,

    [group is sp500]

    and

    [
    [[symbol = $SPX] and [MACD < 0]]

    or

    [

    some other conditions

    ]

    ]

    I think there was a similar question some time ago and I think this worked, but I don't remember. Give it a try (but keep it simple while you are testing it out).

    Found it - here's the previous question:

    http://scan.stockcharts.com/discussion/comment/5081#Comment_5081

    As for software that scans lower time frames - I don't know. Not my thing.

  • Thanks again, i'll play around with it a while.
  • It doesn't recognize [symbol = $SPX]
  • This is a piece of a large scan and how I imagine trying to write the first part of it.

    [[symbol = $SPX] and [MACD Line(12,26,9) > 1 Week ago MACD Line(12,26,9)]] and [Group is SP500] and [RSI(14) > SMA(20,RSI(14))] and [1 Day ago MACD Hist(6,9,0) < 0.0] and [Volume > 500,000] and [Close > 10.0] and [Close < 100.0] and [Close > Open] and [Low < 1 Day ago High] and [MACD Line(12,26,9) < 0.0] and [MACD Line(12,26,9) < MACD Signal(12,26,9)] and [MACD Line(12,26,9) > Yesterday's MACD Line(12,26,9)] and [1 Day ago MACD Line(12,26,9) < 2 Day ago MACD Line(12,26,9)] and [[[Weekly MACD Line(12,26,9) > 0.0] and [Weekly MACD Line(12,26,9) > Weekly MACD Signal(12,26,9)] and [Weekly MACD Line(12,26,9) > 1 Week ago MACD Line(12,26,9)] and [MACD Line(12,26,9) > 0.0] and [MACD Line(12,26,9) > MACD Signal(12,26,9)] and [MACD Line(12,26,9) > Yesterday's MACD Line(12,26,9)]]

    or [[Weekly MACD Line(12,26,9) > 0.0] and [Weekly MACD Line(12,26,9) > Weekly MACD Signal(12,26,9)] and [Weekly MACD Line(12,26,9) > 1 Week ago MACD Line(12,26,9)] and [MACD Line(12,26,9) > 0.0] and [MACD Line(12,26,9) < MACD Signal(12,26,9)] and [MACD Hist(12,26,9) > Yesterday's MACD Hist(12,26,9)]]]
  • Made a little mistake above by leaving out Weekly.

    [[symbol = $SPX] and [Weekly MACD Line(12,26,9) > 1 Week ago MACD Line(12,26,9)]] and [Group is SP500] and [RSI(14) > SMA(20,RSI(14))] and [1 Day ago MACD Hist(6,9,0) < 0.0] and [Volume > 500,000] and [Close > 10.0] and [Close < 100.0] and [Close > Open] and [Low < 1 Day ago High] and [MACD Line(12,26,9) < 0.0] and [MACD Line(12,26,9) < MACD Signal(12,26,9)] and [MACD Line(12,26,9) > Yesterday's MACD Line(12,26,9)] and [1 Day ago MACD Line(12,26,9) < 2 Day ago MACD Line(12,26,9)] and [[[Weekly MACD Line(12,26,9) > 0.0] and [Weekly MACD Line(12,26,9) > Weekly MACD Signal(12,26,9)] and [Weekly MACD Line(12,26,9) > 1 Week ago MACD Line(12,26,9)] and [MACD Line(12,26,9) > 0.0] and [MACD Line(12,26,9) > MACD Signal(12,26,9)] and [MACD Line(12,26,9) > Yesterday's MACD Line(12,26,9)]]

    or [[Weekly MACD Line(12,26,9) > 0.0] and [Weekly MACD Line(12,26,9) > Weekly MACD Signal(12,26,9)] and [Weekly MACD Line(12,26,9) > 1 Week ago MACD Line(12,26,9)] and [MACD Line(12,26,9) > 0.0] and [MACD Line(12,26,9) < MACD Signal(12,26,9)] and [MACD Hist(12,26,9) > Yesterday's MACD Hist(12,26,9)]]]
  • markdmarkd mod
    edited May 2019
    It might be [symbol = "$SPX"], with quote marks around the symbol.

    I'm assuming this scan is not giving the results you expect.

    You have to isolate the symbol = $SPX statement. If you have a scan including "symbol = ...", you cannot have any other "and" statements in the scan meant for other symbols. You can only have an "or" statement.

    Remember, to return ANY symbol, ALL "and" statements must be true for that symbol. If you specify "symbol is $SPX", that is not true of any other symbol EXCEPT $SPX. For instance, symbol = $SPX is not true for AAPL. The symbol for AAPL is AAPL.

    Within the "or" statement you can group "and" statements if you want, but they cannot stand alone outside the "or" statement.

    For instance, you have combined your symbol statement with an "and" statement for group is sp500. That says that you are looking for a symbol that is "$SPX" and belongs to the sp500. These two things cannot be true because there is no $SPX symbol in the sp500 group. So, you will get no symbols back for your conditions before the "or". You may get some for the conditions after the "or".
  • I thought that the double brackets [[symbol=$SPX]] would be enough separation. I'll try the quotation marks around SPX but maybe I should use the word is in place of the equal sign =. In any case, thanks again. I may have to run two separate scans.
  • The quotations corrects it. Thanks
  • Well, the quotes make it run. Not sure about "correct".
  • True. It does run
  • I have just started running scans for gapping stocks using the canned SC scans with a volume filter. I have noticed that sometimes stocks that showed up on the scan near the open will not show up on the scan a little later in the day. Any idea why that might happen? It makes it a little difficult to do any back testing
  • markdmarkd mod
    edited May 2019
    The gap closes during the day.

    If you want to test for just a gap open, you would look for today's open above yesterday's close. That won't change.
  • Thanks, good idea for back testing. I have only just started playing with gaps but sometimes this happens with the gap still open I think. Maybe when price falls back below the open for the day. I'll watch it for a while.
  • I have a couple of fairly short scans for SP500 that work real well when my interpretation of MACD for the market (SPX) is bullish. After yesterday's convo, I presume that there is no way to require the scan to consider a bullish MACD for $SPX before it scans SP500 for stocks?
Sign In or Register to comment.