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.

Can you specify an index (e.g. $INDU) in the parameters on a technical indicator scan?

I'm trying to setup a scan using CCI, Slow Stoch %K, and %B. The scan for equities is working just fine. I now want to add one additional condition to it. I only want it to return long signals when Slow Stoch %K for $INDU is about %D, and only want it to return short signals when the opposite is true. Is there any way to add that check? I haven't found any way to specify that I want the Slow Stoch indicator to apply specifically to $INDU. (Hope that makes sense.)

Yes, I know I can do this manually by setting up a long scan and a short scan, and run one or the other based on the current chart. I'm trying to backtest, though, and being able to include it in the scan itself will greatly simplify the backtesting.

Thanks!
-- Ron

Best Answers

  • markdmarkd mod
    Answer ✓
    This seems to work:

    without the or condition, it returns 43, with it 44, including $INDU

    [[type = stock] AND [country = US]
    AND [Min(126,Daily Volume) > 1000000]
    and [[exchange is NYSE] or [exchange is Nasdaq] or [exchange is Amex]]

    and [[Close > 9.99] and [Close < 70.0]]
    and [ATR(10) < Close*.035]
    and [close > yesterday's close]]

    or [

    [symbol = " $INDU"]

    and [close < 3 days ago close]

    ]
  • KevoKevo
    Answer ✓
    I think you would like to do something like this:
    and [Slow Stoch %K(14,3, '$INDU') > Slow Stoch %D(14,3, '$INDU')]

    similar to Correlation: CORR(xxx, '$INDU', 20)

    In other words, you want to use a symbol as a filter. Your topic question is: can symbols be used as parameter input? Unfortunately, I think the answer is no. This is one reason why we do not have Correlation and Price Relative in the scan engine.

    I know you are backtesting. My suggestion is to run both long scans and short scans at the same time using the 'or' keyword separately or in combination with markd's awesome scan technique. If a lot of short scans hit, then this could be a market changing clue. Otherwise, for today scans, I would determine the market condition, and know in advance whether to run long or short scans.

    BTW, you can have more than one symbol clause linked together with an 'or', and the scan will scan just on those one to many symbols.

    (*) markd: that is a sophisticated tricky way of using the scan engine! I have to better understand what you did. Nice one!

Answers

  • markdmarkd mod
    edited December 2014
    I haven't actually tried this, but I think you could make a list with just one member - the index, and apply the condition to just that list (isolate it with brackets). And then add the rest with "and" and brackets.

    If ekwong is around, he might have other/better ideas.
  • Hmmm, that does not appear to do it. I setup a very simple test to see if that applies the signal just to the index. I created a chartlist called $INDU and it has just one symbol in it: $INDU. To set a baseline, I ran this scan:

    [type = stock] AND [country = US] AND [Min(126,Daily Volume) > 1000000] and [[exchange is NYSE] or [exchange is Nasdaq] or [exchange is Amex]]
    and [[Close > 9.99] and [Close < 70.0]]
    and [ATR(10) < Close*.035]
    and [close > yesterday's close]

    That returns 43 symbols.

    To that scan, I added the following:

    and [[favorites list is 12] // $INDU
    and [close < yesterday's close]]

    Now, since the market did indeed close down, if the theory worked, that would return the same 43 symbols. Unfortunately, it returns 0.

    Seeing it on paper, it makes sense, because the "and" clause at the start would have restricted the entire scan to just that chartlist.
  • So I shouldn't just do things off the top of my head, I guess...

    It looks like you have to do 2 scans, one for the $INDU condition, and if it returns a positive result, then run the stocks scan for that date. But that's probably what you were trying to avoid.

    Instead of a list you can use [symbol = "$INDU] as in

    [symbol = "$INDU"]
    and [close < 3 days ago close]

    then use the calendar to specify the number of days back.

    If you want to do just one scan, what is the result if you use an "or" operator instead of "and"?

    I think if both conditions were true, $INDU would be in the result list. But that's off the top of my head again...
  • Is this what you are trying to do?

    [symbol = '$INDU'] AND [Min(126,Daily Volume) > 1000000]
    and [[Close > 9.99] and [Close < 70.0]]
    and [ATR(10) < Close*.035]
    and [close > yesterday's close]


    If you want just indexes, you can do this:

    [type = index] AND [Min(126,Daily Volume) > 1000000]
    and [[Close > 9.99] and [Close < 70.0]]
    and [ATR(10) < Close*.035]
    and [close > yesterday's close]
  • Once you specify SYMBOL, then the entire scan is restricted to that symbol mask.

    Kevo, I'm not trying to run a scan just on the indexes. I'm ultimately trying to include the value of an index's technical indicator as part of an overall scan. I have a scan that returns symbols based on Slow Stochastic, CCI, and %B conditions that I've set. I'm hoping to also include a Slow Stochastic condition for an index in that set of conditions. I just haven't found a way to do it.
  • I'll play with it, but I don't think it does. Looking at where the brackets enclose the conditions, I think that's including all the stocks that meet the original criteria, and it's including the $INDU since it meets the condition under the "Or". To prove it, simply change the last line to "and [close > 3 days ago close]". For it to work properly, that should return 0 stocks. I suspect, though, that it would return 43. What I'm looking for is to return the stocks that meet the original criteria only if the Index criteria is true.
  • right, but if $INDU it meets the condition, it should be the first entry on the result list (special characters sort first). So if it's not there, the condition isn't met so ignore the other results. I think that's the best you can do.
  • I think you are right, Mark. I was hoping there was a way to add a symbol to an indicator parameter. There's nothing in the Scan documentation that shows it, but I know the syntax used here is common across a wide variety of scanning engines. I've been searching for broader documentation on that syntax in the hopes that it's there. But in the end, I suspect you're right, that it will still be an IEBEYEBALL (old systems programmer slang) which means I'm going to have to look at the results and accept or discard them visually.

    Thanks for spending so much time on this one!
  • Kevo, that's precisely what I was hoping to do. Your suggestion and Mark's creative solution do seem to be the best way to proceed.
Sign In or Register to comment.