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.

How can I scan for an up-side Break-out?

I checked the pre-defined scans in the advanced scan engine and could not find code for an up-side breakout. I also searched S.C.A.N. and did not find any suggested code. Does anybody have a bit of code they use for that? Even better would be code for an upside break-out with a pull-back. But just the Break-out would be just fine. Thanks.

Best Answers

  • Options
    markdmarkd mod
    Answer ✓
    I don't have any ready-made scans for breakouts (because I like pullbacks), but quick and dirty might be:

    [group is sp500]

    and [1 day ago Upper Price Chan(21) = 15 days ago Upper Price Chan(21)]
    and [close > 1 day ago Upper Price Chan(21)]

    You can vary the length of the Upper Price Chan from 21, and you can vary the number of "days ago", from 15 to whatever (but not more than the length of channel). Leave the "1 day ago" as it is.

    The number of "days ago" should probably be more than half the length of the Upper Price Chan length to increase the chances of a meaningful breakout. Note however, that a return to a prior high, especially a longer term one, can also be a double top. The break above should be decisive, on big volume, and the reaction should be on notably lower volume and not get back down to the Upper Price Channel that was broken.

    You also have to be careful that the stock is not in a longer term down trend. In that case breaking a channel, especially a shorter term one, like 21, can be the peak of a short term recovery within the down trend. On the other hand, if the stock has been in a down trend (long term MA is still falling), but the intermediate term MA has turned up AND been tested then the breakout has a better chance. Sometimes the down leg after the intermediate MA cross over doesn't get back to the MA - that's a good sign, but usually there is some kind of pullback, say, to the Lower Price Chan(21), or 20 x Fast K21,1). Then the breakouts have a better chance.
  • Options
    markdmarkd mod
    edited July 2016 Answer ✓
    I mean, for instance, the 63MA had been in a down trend but has turned up, and price has risen above the 63 MA (which it has to do to turn the MA) and then made a leg down from above the MA. Ideally, that leg down should not get under the newly rising MA - either not touch it at all, or maybe a few bars make lows below it, but not highs. And it should move strongly away from that touch.

    Here's a scan that looks for recent 21 day lows. I run it against a variety of lists (not shown), not necessarily the SP500.

    If you run it for dates in late May, you will see what it picks up. Obviously, not all hits are winners, and it doesn't necessarily pick up all winners from the run date. You have to look at other measures like RS, and interpret the price and volume action of the preceding down leg and up leg.

    // 20 00 02 00 Long set up - high low or close in vicinity of recently rising LC21
    // refinement of 20 00 01 00 Long set up - high low or clo less than 1 ATR above or below rising LC21

    // Find stocks where:
    // Lower Price Chan(21) has been rising and the high low or close is within 1 ATR of recent max LC21
    // or K21 has been below 20
    // looking for stocks showing persistent strength (rising LC21), now retreating, hopefully before resuming advance

    [group is sp500]

    // LC 21 is rising

    and [max(5, Lower Price Chan(21)) > 10 days ago min(10, Lower Price Chan(21))]


    // begin OR statement

    // K21 has been below 20

    [min(5, Fast Stoch %K(21,1)) < 20]


    // high is within 1 ATR above or below LC21
    [ absval( high - max(5, Lower Price Chan(21))) < ATR(5) ]


    // low is within 1 ATR above or below LC21
    [ absval(low - max(5, Lower Price Chan(21))) < ATR(5) ]

    // end OR statement

    Here are two examples, one a winner, one a loser from May 24. Note that the winner contradicts the suggestion above about not breaking the rising 63 MA. It "cancels" that conclusion by making a double bottom and breaking above the high in between on huge volume. You might have "guessed" that a double bottom was in the works because the big down volume bars in the down leg were poorly formed, and in spite of all that down volume the was no new price low, showing strong "hidden" buying.

  • Options
    markdmarkd mod
    Answer ✓
    Hi @BobS ,

    1. I chose 21 because it is the average number of trading days in a month. It's arbitrary, but to my mind it seems most parameters are, even if they are based on research. I'm not always convinced of the quality of the research. I like calendar based parameters for everything - 10 (two weeks, or half a month), 21 (a month), 63 (a quarter), 251(a year). Intuitively, it seems the market is likely to be affected by the time frames associated with economic and emotional cycles tied to the calendar.
    2. The reason for including the ATR conditions is to capture all the likely possibilities. Fast K looks only at the close. You would hate to miss something because K21 read 20.07 or 22.30 but the bar shows trading has been very close to or across the lower channel.
    3. You can run it against everything if you have time. Stocks don't always move in sync with the market, their sector or industry, so it's possible to get a hit anywhere. But I would start with sectors where the SPDR 63 MA is rising, and the RS for the sector against the SPX (e.g. XLB:$SPX) has a rising trend to it. Then look at the stocks in the industries ($DJUS indexes) with the same characteristics. It tends to work out that you get few hits for quite some time, then two or three days where you get a slew of them.
    4. I have industry lists built from scans that filter for preferred characteristics - trade only on NYSE or NASDAQ, not PINK or OTCMKT, etc. market cap over 100 million and volume over 50K, then rank by market cap. This includes stuff I normally wouldn't want to trade, but those are ranked near the bottom, while the institutional stuff is at the top. You can find lower priced, lower volume stocks that trade as if they were sponsored - i.e. they trade like institutional stocks - so you don't want to miss a chance to consider those when they turn up.
  • Options
    markdmarkd mod
    Answer ✓
    You can be reasonably sure of institutional involvement with [group is SP500] or even [group is SP400]. That's not a guarantee of sponsored trading, but it helps. For liquidity, a monthly average volume over a million shares a day is probably a pretty good rule of thumb. But if the chart doesn't show frequent wide gaps or sudden expansions of range, (signs of illiquidity) you could go lower. However, you can get caught by news at any time even in well behaved stocks (like Brexit, the flash crash, earnings events) . Sometimes in retrospect you can see the news coming (something about the stock's behavior changes - for instance it shows good strength in an up leg, but then fails to follow through on good volume) but its hard to catch in real time.
  • Options
    markdmarkd mod
    Answer ✓
    I wish I could say that there were "rules" for placing orders and stops, but it's more like there are "guidelines" for events or patterns or situations where the probabilities should be better, based on what those things seem to be saying about the balance (or imbalance) of buyers and sellers. But they don't necessarily work out, even when it looks like a slam dunk, and a lot of times, the situation really isn't clear to begin with. In the moment, it's easy to miss indications that are evident in retrospect. No matter how hard you try to be objective, your biases are operating. The market has an infinite variety of ways of showing these imbalances. You will always be in doubt.

    That said, regarding question 1, I'm not sure which answer you are quoting from with " one sign of this capitulation is when there is a very large down volume day but which moves price down very little". I can think of two situations where this could work out. If other factors on the chart show consistent buyer dominance, like RS (MA 21 rising) and Force (hanging above its intermediate and long term rising MAs) and the direction and position of the intermediate and long term price MAs (both rising, intermediate above long) and price and volume (high volume, good form up bars and high volume down bars, if any, all or mostly bad form), then buyers will jump on this sign of weakness and your tactics should work. Or, if a down trend has been in effect for some time, and the event occurs near prior support or at a confluence of indicators, it might work, too. In other words, if it occurs where you would expect a bottom to occur any way in both price and time, it would be a more reliable indication. If it happens while the stock is in an up leg, or earlier than you would expect in an up trend down leg, its probably better to wait. For "ordinary" lows in an uptrend, its a surer thing if buyers show strength first (close above a high, preferably on higher volume) and then sellers, on a higher (not necessarily huge or even above average - May 25 on AEE) volume bar(s), cannot break the recent low or make a new low close (for the current down leg). This doesn't always happen, so you could miss trades if you wait for it. But if you passed on a trade (because no clear entry), and then see this, you could take it.

    On question 2, when the stop distance is too large, either don't take the trade or reduce your initial position and add to it when the action gives you more confidence, or put the stop somewhere within the tail, if the intraday chart shows a likely support level. Look at the stocks recent history (several months) to see what it does with these candles. Behaviors often repeat.
  • Options
    Answer ✓
    @MarkD thanks again for this scan for pullbacks. How would you scan for a correction, which for instance would have picked up ABX on Sept 6 but not ABX on July 25? I have added this to the question on pullbacks so that you could easily see the scan you gave me for the pullbacks. But I think I can give you points for it again by just noting another as an answer. Is that true, or do we need to break this off to another question?


  • Options
    Thanks @markd . By "the intermediate MA has turned up AND been tested" (last paragraph) do you mean price has broken through a resistance point?

    Also, like you, I think I might prefer pull-backs. I would love to know how you scan for those.
  • Options
    1. I now understand well (not only with your explanation but also with the example at the bottom) what you meant by the rising intermediate term MA needing to withstand the test.
    2. I gained good insight from your comment on AEE that you could have "guessed" that a double bottom was coming because the candles for the huge down volume days were not well formed (and especially not able to hit a lower low). Thanks.
    3. On the AEE trade, which day (or days) would you have bought this stock? Would you have bought on May 20th, 24th or 25th with a stop at about $45.50 or bought on June 6 with a stop about $48?
    4. After I digest the scan and I try it out a bit, I may have a question about it.

  • Options
    markdmarkd mod
    edited July 2016
    Safe entries on retracements are tough. You don't want to give up gains, yet you don't want to get underwater for very long. You could wait for May 31(or June 6), but that is a breakout trade and you give up 3 points (from the absolute low).

    The ideal entry is immediately after sellers have clearly capitulated. Sometimes that is clear, other times you can't be sure. Almost always, there is a local trend reaction to any counter trend event. So on AEE, May 19 closes up, above the midpoint, on wide range and low volume. That is a counter trend move (using the direction of the a short MA, like 3 or 5, to describe the local trend), but an ambiguous one because its a down bar (lower high and low) and the volume is low. If the down trend is strong, it should be able to defeat that move.

    On May 20, it looks like sellers will defeat the move because the up bar (buyer follow through) closes down on high volume. So higher prices are attracting selling, as they should in a local downtrend.

    On May 23, the good form down bar makes a new down leg close, but it's on very light volume. Lower prices are not attracting new sellers (or buyers).

    On May 24, buyers return, but again on very light volume. Form is good, but range is only moderate compared to the prior bar, and the close is lower, so buyers are weaker than the prior up close. But - at this point, the local trend is still down - buyers are expected to be weak. Sellers have the obligation (so to speak) to make new lows, and they haven't done so for three days.

    On May 25, more sellers than buyers show up (down close on higher volume), but they cannot make a new low close against weak buying. In a down trend, when there are more sellers than very weak buyers but they cannot break the prior low, or make a new close, they, too, must be very weak.

    On May 19 and 24, buyers showed they were willing to take the initiative. We can guess that they will be willing to try once more, having proof of seller weakness (in an up trend it's pretty safe to assume that buyers want to buy, until you see that they don't). So, if we want to join them, we could put in a market order for the next open (May 26), or a buy stop above the May 20 high (last best effort of the buyers) or the May 24 high (most recent best effort).

    We don't know whether higher prices will attract more selling again. We only know the down side is not attracting sellers in an intermediate and long term up trend (63 MA rising above 251 MA rising). Depending on your confidence, you might put a stop under the May 19 low (last best effort of sellers, or the May 23 low (second best, most recent effort).

    Bottoming patterns don't always develop so neatly. But if they are going to work, USUALLY, they will not retrace much below the mid point of the strongest counter trend bar (like May 19). So, once you see the strong bar, you could put in an order around that mid point with a stop under its low or a nearby low that represents the max strength of sellers. That's aggressive, and you could get stung, but not too badly, as long as the longer trend is up and there haven't been many (or better, any) high volume, good form down bars breaking the lows of strong up bars.

  • Options
    All of this explanation was exceptionally helpful. You gave several possible entry levels and several possible stop levels. The smallest stop (risk) I would encounter would be about 1%, which would be if I bought just above the midpoint of the May 19 strong up bar and put in a stop just below its low. The greatest stop (risk) would be if I placed my entry above the top of the bar on the 20th and put a stop just below the low on May 19th, which would result in a stop more than 2.7%. You suggested some other possible entries and stop levels which would result in risks between 1% and 2.7%.

    Taking into consideration all your chart tells you about the price-volume action during this period (but of course not knowing the future of the stock after May 26), where would you put your own entry and stop?

    Thanks again, BobS
  • Options
    markdmarkd mod
    edited July 2016
    Well, the real question is, what would you do, keeping mind that no two situations are the same and only you can make your own decisions. It's your risk tolerance that matters, not mine.

    I probably would have passed this one over in real time, because there is only so much time to analyze, and this one broke the MA 63 pretty seriously, which is usually a disqualifier for me.

    But, assuming I took the time to think about the potential double bottom, and came to the conclusions outlined above, hindsight being 20 20, I think I would have wanted to play this one aggressively - on the night of May 19, put in an alert in around the midpoint of that bar, which would have been triggered on May 23. At that point, since the market closed below it, enter the order at that midpoint (or look at the intraday action to see if there's a better place). Place the stop under the May 19 low.

    You could be aggressive on this one because, in addition to the price/volume action, the SCTR has improved tremendously vs the prior bottom (30ish to 70ish) and the red RS (AEE:$DJUSMU), the stock vs. its sector, is ticking up, too, even on down bars (May 17, 18), showing this is a preferred stock in its group.

    Note again, I'm not saying I would have chosen this stock to trade from all those in the scan results. I randomly picked this one (with the other one) in hindsight to illustrate the range of possible results, and that the scan itself picks both winners and losers, and choosing the best trade requires more work. No magic bullets.
  • Options
    @MarkD, this is VERY helpful. I know that is MY risk tolerance that must determine when I trade. But, your comments were quite useful. I have a good bit of homework to do now with the Scan itself, which may stimulate another question.
    But, these comments inspire me to use alerts more. Do you do these through StockCharts? Also, why would the alert you mentioned that you might have considered putting in the evening of May 19 not have triggered on May 20 or 21, both of which had points during the day when price was above the midpoint on May 19?
    The answer to that question may help me know how to word alerts more wisely. Thanks again.
  • Options
    Oops. There was no trading on May 21; so, my question is only whether the alert might have been triggered on May 20.
  • Options
    On the 19th, AEE closed above it's midpoint, so the alert would be for it to cross back below that midpoint. The reason is, you want to see how the stock behaves on the reaction to counter trend strength (if there is one). There really is nothing to prevent big selling from suddenly coming back. So, for instance, if it crossed back below the midpoint on strong volume and broke the low, the trade would be off. You wouldn't want to have an order sitting there and getting caught. But if it broke it gently, and came back, then you would want to be in. You don't have to use alerts - I'm assuming most people on this forum don't have regular access to the market, so that's how they would do it.
  • Options
    Very insightful answer, as usual. Thanks. I have tested the scan a bit now and have a few more questions.
    1. How did you select 21 as the Lower Price Channel to test for? Is there another reason besides the fact that 21 is the number of trading days in a month?
    2. Does checking for 1 ATR from the Lower Price Channel of the High and the Low as well as the Stochastic being below 20 give you more good hits to choose from?
    3. Do you use this scan to catch stocks after a correction or just just stocks which are clearly in an uptrend and now pulling back?
    4. You mentioned above that it is safer and more profitable to trade a stock which is also part of a sector which is rising out of a pull-back and using a sector performance chart to find these sectors. So, I assume that you then run this scan on stocks in those recovering and preferred sectors. Rather than run it on all stocks in that sector, do you filter that large number of stocks for other traits (either through a scan or visually on the charts)? The reason I ask this question relates to suggestions you have made in the past for preferring stocks whose bars "behave more like they have professionals trading them" (more nicely formed bars). Have you compiled a short chartlist of stocks for each sector which typically have more well formed bars?

    Thanks so much. BobS
  • Options
    @MarkD I marked several of your answers above as answers. I hope I can still ask a few more questions here. If so, here they are.
    1. Do you find the sectors (and then industries) with 63 MA and RS vs SPX both rising by a scan or customized candle glance charts?
    2. How many industry lists have you built?
    3. In selecting stocks for these industry lists which act like institutional (or sponsored) stocks, I suspect you look for a predominance of well-formed bars. Are there other things you look for, like a more predictable period between peaks and troughs?
  • Options
    Hi @BobS , thanks for the answer credits.

    1.There are only 9 sectors so those are easy enough to view in Candleglance. My Candleglance chart style includes RS (vs SPX), which you can't scan for anyway. Likewise with the industries within the sector (with RS against SPX and also the sector). I have used scans to rank them by ROC over periods of time, but after doing that for a while I found eyeballing RS is OK. Not precise, but its not really a game of precision.

    2. I have an industry stock list for every $DJUS index. So its one list for the SPDR sectors, then for each sector, a list with the all the DJUS indices (per the listing in the Sectors and Industries drop down, which can vary from other sites like Finviz and Yahoo), then for each index a list of stocks filtered as explained.

    3. The industry stock lists are all stocks that pass the filter. I don't edit the industry lists beyond the filter because price behavior for individual stocks can vary over time. So some that you might exclude for being too volatile or irregular later calm down, while formerly well behaved stocks can fall apart. The point of having the industry lists is they serve as targets for your scan when the sector and/or index shows positive signs. Often its the biggest market cap stocks that are moving the index, but there can be followers (or even leaders) in the lower caps.
  • Options
    This makes great sense, not only answering the questions I asked, but also answering some questions that I had not thought of. 2 more questions:

    1. If I were to raise my minimums for market cap and/or volume, are there levels above which almost all of the stocks would either have institutional support or act as though they do?
    2. What is the minimum amount of daily volume you prefer to make sure you have enough liquidity to get out quickly if you need to?
  • Options
    Oh good. I will feel much safer with Large and Mid Caps and with Volume over 1 Million per day. The industry scan guidelines on July 30 that mentioned "volume over 50K" sounded like more liquidity problems than I am capable of handling. Now I realize that I needed to pay more attention to your comment that "This includes stuff I normally wouldn't want to trade, but those are ranked near the bottom, while the institutional stuff is at the top."

    2 more questions would really help.
    1. Above you said something very helpful, namely "The ideal entry is immediately after sellers have clearly capitulated." As I have learned from you in the past, one sign of this capitulation is when there is a very large down volume day but which moves price down very little. It would seem this would be a great time to buy because sellers have been worn out by buyers and because there is a small distance between the trough where you should set the stop and the day's high above which you should need to set the buy order. Is that right?
    2. What I am less clear on is another candlestick pattern that seems to indicate that the sellers have capitulated, namely a hammer or inverted hammer. Unfortunately, both of these have a long stem (wick or tail). Do you have a suggestion of how to handle these situations without a huge stop?
  • Options
    Also, as you mentioned, this scan can at some times give you a large number of hits. For instance I ran it today even asking for only those over 1 Million average volume and still got well over 100 hits? Do you look at all of these charts visually?
  • Options
    On big hit lists:

    Most industry groups have fewer than a hundred stocks, so if you first determine the strongest sector and/or industry RS (or recovering RS) and scan only against that first, you will probably get fewer hits. Or you could rank results for your present scan by either industry or sector and concentrate on the hits from the sector or industry getting the most hits, on the (not necessarily valid) assumption that that area of the market is getting significant attention. (This is a reason to include stocks in your list you might not trade - to see what is the interest in the industry or sector). Or, in Candleglance, eliminate anything that has a downward sloping RS line (symbol:$SPX). If that still leaves a lot, look for the ones with the most regular price and volume action and very few or no disqualifying negative events - like solid red down bars that break support on notable volume, from which recovery was weak. You want to see that sellers haven't been winning cleanly (good form and above average volume) recently, or if they do, buyers come right back. This last is easier to see in 10 per page view.
  • Options
    @MarkD: Thanks for both of these answers. Since I think that the answer to the first question is more likely to help others, I marked it as another of the "official" answers. Thanks again. Quite helpful!
  • Options
    I think you could use the same scan, but substitute K63 for K21, and LPC63 for LPC21.

    Thanks for your concern about giving credit for answers - much appreciated. Not critical, though - I enjoy the process, so the "points" are gravy.
  • Options
    @MarkD I was pretty sure that was the answer. Thanks. It makes sense and helps a lot.
Sign In or Register to comment.