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.
@jparaiso OK. This is pretty easy to do yourself. The only "tricky" part is the "x" operator, which means "crosses above".
Here are the basic rules for writing a scan (give me 5 minutes):
Every statement begins with “and” except the first one.
Every statement goes between square brackets [ ].
Parentheses are reserved for indicators and functions, like RSI(14) or max(10,close). If you need to group arithmetic expressions, use more square brackets, not parentheses: For instance:
and [ [high – close]/max(10, close) > 10]
Every statement contains an operator. Valid operator are: is, is not, >, <, =, !=, >=, <=, x, contains, not contains.” !=” means “not equal to”. “x” means “crosses above”.
Every statement has one value preceding the operator and one value after the operator. Some examples:
[group is SP500] // this would be a first scan line because no "and" in front
and [MACD Line(12,26,9] > 20]
and [MACD Line(12,26,9) x MACD Signal(12,26,9)]
and [close > 2 days ago high]
You can also write “or” statements.
“Or” statements need to be isolated with an extra set of brackets
// begin scan // get bullish and bearish crossovers
[group is sp500]
and
[ [ MACD Signal (12,26,9) x 20] Or [ 80 x MACD Signal(12,26,9)] ] // end scan
The double slashes "//" tell the scan engine to ignore everything on that same line that comes after the "//". So you can use that space to explain to yourself (for later) what you thought you were trying to do in the scan code.
NOTES on scan logic with “and” and “or”:
If a scan has only “and” statements, all the “and” statements must be true for the scan to return a symbol.
If a scan has a mix of “and” and “or” statements, the results depend on whether you isolated the “or” statement with extra brackets as shown above.
If you don’t use the brackets, then only one condition in the entire scan has to be true to return a symbol.
If you do use brackets, then every “and” condition must be true AND at least one “or” condition must be true to return a symbol.
So now, for your scan, on the Advanced Scan page, find the Technical Indicators drop down.
Select Slow Stochastics %K (fast line) and insert it Select Slow Stochastics %D (slow line) and insert it
Edit the two lines into one line by deleting the operators and constants (numbers) on the right side of the operators. Put the "x" operator between %K and %D (like the MACD example above). Check that the line starts with "and" and you have one pair of square brackets around your condition. That is a bullish crossover. For a bearish crossover, reverse the position of the %K and %D so %D is first.
Let me know if you can't figure it out by posting what you have so far.
Ideally, I would like to see the fast line crossing over the slow line in a bull or bear direction. Additionally the same crossover when the crossover is made above or below the 80 or 20.
markd, thank you for your help!! This is exactly what I was looking for. I know nothing is ever 100% but I like the price movements I have researched with this type of scan. Here is what I have so far. This particular scan is for a overbought bear position. I ran the opposite scan for a bull position less than 20 stoch oversold.
[type is stock] and [optionable is true] and [Volume > 1,000,000]
and [Slow Stoch %K(14,3) > 80.0] and [Slow Stoch %K(14,3) > 0] and [close < 1 day ago high]
One minor thing - I'm not sure what you wanted to do with this line:
and [Slow Stoch %K(14,3) > 0]
If % K is greater than 80, it is also greater than zero, so this line isn't necessary. But it doesn't do any harm, either.
Since this is a bearish scan, you may also want to add a test for a down trend.
and [sma(251, close) < 21 days ago sma(251, close)]
You could experiment with the 251 parameter - 200 or 150 maybe or even 50. You might use fewer "days ago" with shorter sma parameters, maybe 10 or 15 days.
In an uptrend, a Slow K% above 80 is not as reliable, It can be the beginning of a longer up leg.
Both versions of the indicator you want are written incorrectly. If instead of writing them "free hand" you select and insert the indicators you want to use from the "Technical Indicators" drop downs in the Scan Builder section under the Scan Criteria window, you will get the syntactically correct default version of the indicator(s) you choose, so you don't have to guess.
If you select and insert Slow Stoch %K and Slow Stoch %D, you will get
and [Slow Stoch %K(14,3) > 80.0] and [Slow Stoch %D(14,3) > 80.0]
Then you would edit those two lines for your custom parameters and put them together for the condition you want.
Answers
I really appreciate your help!!
[type is stock]
and [optionable is true]
and [Volume > 1,000,000]
and [Slow Stoch %K(14,3) > 80.0]
and [Slow Stoch %K(14,3) > 0]
and [close < 1 day ago high]
One minor thing - I'm not sure what you wanted to do with this line:
and [Slow Stoch %K(14,3) > 0]
If % K is greater than 80, it is also greater than zero, so this line isn't necessary. But it doesn't do any harm, either.
Since this is a bearish scan, you may also want to add a test for a down trend.
and [sma(251, close) < 21 days ago sma(251, close)]
You could experiment with the 251 parameter - 200 or 150 maybe or even 50. You might use fewer "days ago" with shorter sma parameters, maybe 10 or 15 days.
In an uptrend, a Slow K% above 80 is not as reliable, It can be the beginning of a longer up leg.
and [todays Slow Stoch Line(5,3) x todays Slow Stoch Signal(5,3)]
but it throws a syntax error so I've tried multiple variations
and [todays Slow Stoch Line %K(5,3) x todays Slow Stoch Signal %K(5,3)]
but still getting syntax errors
any suggestions would be appreciated.
If you select and insert Slow Stoch %K and Slow Stoch %D, you will get
and [Slow Stoch %K(14,3) > 80.0]
and [Slow Stoch %D(14,3) > 80.0]
Then you would edit those two lines for your custom parameters and put them together for the condition you want.