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.
[type = stock]
and [today's daily SMA(50) x today's daily SMA(200)]
How can I take this syntax and write for SMA(50) a percentage away from crossing? My goal is to catch the crossover early
0
Comments
[type = stock]
and [ [exchange is NYSE] or [exchange is NASDAQ] ]
and[ [Close >=SMA(50,close) *0.98] x [ SMA(200,close)]]
and [[Close >=SMA(50,close) *1.02] x [ SMA(200,close)]]
You are not looking for the actual crossover in the scan, you are looking for the two MAs being close to each other. So, you can eliminate the "x" operator.
Also, you probably don't care about where the close is because it's the MAs that cross in a golden cross. So you can eliminate references to the close.
Also, as a point of syntax, you can not have more than one operator (>, <, =, x, etc.) for each "and [ ... ] " condition. A condition is (almost) always the word "and", the opening and closing brackets "[ ]", an operator (>, <, etc.) and the two terms compared by the operator, one on each side; for instance, in this condition "and [close > sma(10, close)]", close is a term, and sma(10, close) is a term.
So this statement, even if it passes syntax, is wrong:
and[ [Close >=SMA(50,close) *0.98] x [ SMA(200,close)]]
You have the right number of brackets, and they are well placed, but assuming the "close" condition is true, this line says "true crosses above MA 200", which is not meaningful. If you think about it, how would the scan engine decide whether you want the close or the SMA crossing above the 200 MA? The syntax checker should flag this, but I'm guessing it doesn't, so don't feel bad.
So, re-thinking things a little:
What you need to know is the direction of the two MAs and whether they are close to each other.
A golden cross happens when the 50 MA crosses above the 200 MA from below.
So there are several tests that you need.
One is that the 200 MA is falling. A way to test that is to scan for today's 200 MA less than the 200 MA some number of days ago (you decide how many).
Then you need to test that the 50 MA is rising, or greater than it was some number of days ago.
Now, if you want to catch the golden cross before it actually happens, you can test whether the 50 MA is some per cent less than the 200 MA. Probably the easiest way to do that is to test for 50 MA < 200 MA and 50 MA > 200 MA * .?? (.?? means some decimal fraction corresponding to the distance between them as a per cent; note: two separate statements, not one).
If you want to catch it some time after, you can test whether the 50 MA is some per cent greater than the 200. In order to insure a crossover, you might want to test that the 50 was less than the 200 some number of days ago.
Give that a try and if you get stuck, post what you have.
I was trying to create this same thing when I found this post. I have more to this but this is the "meat" of what I am looking for. I don't see why it isn't producing "a lot" of results? Note, I am also looking for stocks below the 200 MA. Essentially looking for the crossover lower than normal.
and [[[1 day ago SMA(13) < 1 day ago sma(30)] and [0 days ago SMA(13) > 0 days ago sma(30)*0.98]]
or [[2 days ago SMA(13) < 2 days ago sma(30)] and [1 day ago SMA(13) > 1 day ago sma(30)]]
or [[3 days ago SMA(13) < 3 days ago sma(30)] and [2 days ago SMA(13) > 2 days ago sma(30)]]]
I can obviously change my MA numbers but I use 13/30 most of the time.
I have also gotten results where my shorter MA is crossing from above vs below, any thoughts to that? Sorry to hijack someone else's post!
To test this, look at an index chart, find dates when the market is rising (in an up leg) and falling (in a down leg), and run the scan on those dates. The number of results should vary noticeably.
Another possibility for too few results is that your additional conditions not shown are too restrictive in some way.
I ran the snip of code and it returned over 700 matches.
So to do this the right way, the code must be some how combined with a search for bullish MACD, STOCHATIC or RSI..
Do you know of any scan that does this?
Thank you for all your time and help!
Kimberly
I would love to be able to catch these stocks right before the crossing and move higher..
These scans have to be out there somewhere unless nobody wants to share the secrets..
Greed gets people nowhere..
If you get too many hits to review, you have to decide how to narrow the results.
What kind of stocks do you want to work with? Index only stocks, like Dow 30, SP100, SP 500, NAS100?
All big, small or mid caps? Health, technology, materials stocks? High priced, mid priced or low priced? Add conditions to the top of your scan to limit what you look at. It may take some experimentation to decide.
Also, there doesn't "have to be " a scan for complex patterns like you have illustrated here. For instance, it's pretty much impossible to scan reliably for "double bottom low" because they can be a different number of days apart at different times. It's also difficult to scan for events like the Golden Cross that happened in the past. How far in the past? It will vary from stock to stock. How do you code for that? Complex pattern scans are not going to be widely available because they are not reliable.
As Chip has pointed out in his videos, the scan engine is designed to pick up "signals", mainly indicator crossovers. It can find some patterns, but the results will always be catch some good hits and miss some good hits, and pick up some junk, too. People are pretty generous with sharing their knowledge on this site, so don't assume anyone is being "greedy".