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).
Thank you


  • Options
    I think we'll need a little more information before we can help you write a scan.

    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.
  • Options
    consolidation of price formation. Prices trade in a narrow rage and it breaks out of that price range with higher volume; time period of consolidation say 5 weeks; but I will tweak it to 10,15..weeks. I am not using any indicators for identifying consolidation.
    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)
  • Options
    markdmarkd mod
    edited February 2015
    You could start with Chart School on this site. Many of the articles recommend books for further reading. I think maybe Bollinger Bands, Bandwidth, maybe %B indicator would help with your question. Maybe also Price Channels.

    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.
  • Options
    I am trying to start with basics and tweak it from there for accuracy.

    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

  • Options
    markdmarkd mod
    edited February 2015
    Hi 36Kashili

    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.
  • Options
    Have a look at the webminar Chip recorded on Feb 7, 2015 - maybe it'll provide you with some ideas.
  • Options
    edited April 2015
    [type = stock] AND [Daily SMA(20,Daily Volume) > 40000]
    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 %
  • Options
    @Daneil: Interesting comment. As I am reading BB Width, I figure I am looking for stocks that broke out of BB squeeze over 90 days (that is: for last 90 days they were consolidating or channel is narrow; but the stock broke that channel today). Any comments on how I would tackle that?
  • Options
    edited May 2015
    If it broke above the channel, then you go long. Broke below the channel, then you go short.
  • Options
    I normally draw a line that connect 3 or more highs and 3 or more lows.
    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.
  • Options
    @daniel_fromcebu: Intuitive explanation. Thank you
Sign In or Register to comment.