It looks like you're new here. If you want to get involved, click one of these buttons!
Other Charting Tools
Saved Charts and ChartLists
Other StockCharts Questions
Using Technical Analysis
InterMarket and International
Market and Breadth Indicators
S.C.A.N the StockCharts Answer Network forum
Using this StockCharts Answer Network forum
The Cogitation & Rumination Emporium
Forum Test Area
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.
What is the scan formula for a stochastic crossover?
edited April 18
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]
[ MACD Signal (12,26,9) x 20]
[ 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.
Do you mean %K crossing %D ? If so, which direction? Or do you mean crossing above 20 or crossing below 80? And do you want Fast or Slow Stochastic?
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.
I really appreciate your help!!
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]
OK, that looks good.
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.
Powered by Vanilla