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.
Using SPY as a filter in scans.
I had an idea that I would use SPY as a filter to easily decide if I should buy stocks. Yes, I know I can simply look at SPY on a daily chart and look at its ema in an overlay. But for the sake of learning if I can include it in a scan, I'm asking the question.
So, for example, if I make a trading rule that I will not buy stocks when SPY is below its daily ema(12), then the scan results should give me a return of 0 on days when that conditional filter is met. I tried the syntax " AND [ SPY > EMA(12) ] ", but that doesn't work, as there is no relationship in that syntax that connects SPY to its own ema. I'm currently stumped as to how to proceed.
All feedback will be appreciated.
0
Answers
[symbol is "SPY"]
and [close < ema(12,close) ]
If it's true, the results will return SPY, if not, no results.
But, the scan language does not support "if...then" statements, so I don't think you can use the code above as a switch to determine whether to run the rest of the code.
Also, you couldn't write this and get what you want:
[symbol is "SPY"]
and [close < ema(12,close) ]
and [favorites list is ??]
and [MACD Hist(12,26,9) x 0]
SPY would have to meet both conditions and symbols in the favorites list that weren't "SPY" would not be selected because "symbol is SPY" is required. A symbol must meet all conditions to be a hit. You can't isolate them, except through "or" statements. But in your case, I don't think there is an "or" combination that will work.
Thanks for trying to help!
I tried " and [ CLOSE (symbol is SPY) > [ EMA (12), ( Symbol is SPY) ] ] "
This line tells me that SPY is greater than its own ema(12).
The syntax is correct, according to the "Check Syntax" function. However, the Scan Results came back with "The Scan Engine is taking too long to return your results. Please try again later."
Any thoughts?
So the syntax now looks this way: and [ CLOSE (symbol is 'SPY') > [ EMA (12), ( Symbol is 'SPY') ] ]
But I'm still getting "The Scan Engine is taking too long to return your results. Please try again later."
I thought I had it that last time...bummed!
This syntax is also correct...
...but I'm still getting "The Scan Engine is taking too long to return your results. Please try again later."
Ideas, thoughts?
The conventional way to set up a scan is to specify the groups of symbols you want to look at at the top of the scan and then the conditions you want those symbols to satisfy in the body of the scan.
You have broad discretion in how to specify the groups you want to look at. You can specify a single symbol, as I showed you above, or you can specify a group like
[group is sp500]
or you can specify some kind of characteristic(s)
[exchange is NASD]
and [market cap > 100]
and [volume > 10000]
and so on.
But you couldn't write
and [close (exchange is NASD and market cap > 100 and volume > 10000) > [ema(12, (exchange is NASD and market cap > 100) and volume > 10000] ]
The scan engine isn't designed to interpret that format. It may not violate any syntax rules but that doesn't always mean it will work. When it "takes too long", that's a good sign the interpreter is having a problem with the code as written.
Your method of specifying the close of a particular symbol inside a condition like close > ema(12, close) is not legal. You have to do it the way I showed in the previous post - the symbol or group of symbols is one condition, the indicator states are a separate condition. If all statements are true - that is, the indicator condition is true for one or more symbols in the specified symbol or group of symbols, then you get results - the symbol or a list of symbols belonging to the group which satisfy the indicator state specified.
I really appreciate your quick reply and thoughts on my query.
So this is what I'm thinking now:
1. If the scan engine is saying that [ CLOSE (Symbol is 'SPY') > Daily EMA (144, Symbol is 'SPY' ) ]
is correct, would you also agree to that?
2. Even if the scan engine isn't able to make the interpretation, my next thought would be to wonder if the software developers are willing to give the scan engine the robustness to allow for "...a switch to determine whether to run the rest of the code." I take it--from your expertly demonstrated knowledge--that you are one of the software developers, and would be able to authoritatively answer my wondering thought.