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.
code for consolidation breakout
How can I scan for US stocks that break out of 5 week consolidation (or 25 days).
What does a consolidation look like to you?
Which indicator(s) and/or overlay(s) would you use to identify a consolidation?
Note that no two consolidations will be exactly alike, so no matter what you choose, it will miss some consolidations you would like to see, and include some that aren't really what you want. But something is better than nothing, so give it some thought and let us know.
Markd: I am beginner, you last 2 lines are interesting; but I cant think in terms of indicators (and would love to, if you point me to any resources/books on identifying patterns based on indicators)
I would just add, there are no right answers. But to come up with a scan, for the computer's sake you have to be very specific about what you want - for instance, you said 5 weeks, which is specific, but what is a "narrow range" to you - 1 point, 5, 10, 20? What's higher volume? higher than yesterday? the 10 day average? the 50 day average? And so on. It takes a while, sometimes quite a while to figure out what you really want. But it's doable with some patience. Just take it one step at a time and then put the steps together.
Others might want to weigh in as well with other suggestions.
Volume is twice the average over 5 recent weeks
Coming out of consolidation can be defined as where following criteria holds:
-today's ATR is twice the average of last 5 weeks ATR
OK. That's good. A few more questions:
1 - what is the length of the average for volume?
2 - ATR is already an average, so I'm not sure what you are thinking here.
Do you want ATR(25) > 1 day ago ATR(25)*2?
You probably won't get any hits with this (try it), because an average will rarely double in one period (because an average is calculated by dropping the last term and adding the new one, so the new value is diluted by subtracting it from the dropped value and dividing the remainder by the length of the average. Even a very large new number will only move the average a relatively small amount).
or do you want range > 1 day ago ATR(25)*2
This can work. Today's range is twice the average of the true ranges that occurred over the last 25 days (5 weeks).
or do you want range > sma(25, ATR(?)) * 2
This can work, too, but it's different from the last one. This one says today's range is 2x the 25 day average (sma(25,...)) of the average true range over some period (ATR(?)). In practical terms, the results probably would not be much different, unless the ATR(?) parameter - ? - is something dramatically different from 25.
and [BB Width(25,2) <=5]
# make sure the 8, 20, 50 SMA are close together. The Bollinger band width is less than or equal 5 %
Connecting lines is an art and it's not perfect FYI. When it breaks those lines, then you can decide
to go long or short. Consolidation means we are in a state of equilibrium. If somebody wants to buy
the stock badly at this prices ,then a breakout happens. and vice versa for selling.