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.

Scanning for a failed downside breakout

Hi,

I am looking for a scan that searches for the following setup:

- Price has been in a downtrend
- Price takes out the prior low but not by much and then closes above the prior low
- MACD shows a shallower bottom on the pierce of the low than it did at the low that has been pierced (a divergence)

Can anyone help me set this up?

If this is too hard, is it possible to do it without the divergence between price and MACD? So only the takeout of the low by a small amount and then closing above the low that has been taken out?

Thanks!

Akroma

Answers

  • markdmarkd mod
    edited March 2015
    What do mean by "prior low"? the low of the previous bar, or the low of a previous decline?

    Also, what do you mean by a downtrend? In what time frame - in other words, are both the 200MA and 50MA declining, or just the 50MA above a rising 200MA, or something else?

    Often the problem in writing a scan is not the grammar or the syntax or even the logic, but deciding exactly what it is you want. So the more specific you can be the better. Your description is good - it just needs to be a little more concrete, in the way the above questions suggest.
  • Thanks for making me think about this :smile: . You are correct in the sense that figuring out what exactly you want is the hard part.

    So with that being said:
    For this example I would define a downtrend as the 13EMA has to be below 26EMA for the previous 50 days. This is not the problem though, I have this programmed already.

    What I mean by the prior low is the low from the last decline. So not yesterday's low. This has proven to be a bit of a problem to program.

    For MACD I want it to have a decline to a deep low, then a rise above 0 and another decline to a higher low. I can add a picture of this in my next reply if necessary.

    Regards,

    Akroma

  • markdmarkd mod
    edited March 2015
    For finding a break in a previous low, you could use price channels, e.g. something like

    // test for lower channel has been at the same level for some number of bars

    and [1 day Lower Price Chan(21) = 7 days ago Lower Price Chan(21)]

    // test for break below and close above that price channel

    and [1 day ago Lower Price Chan(21) x low]
    and [1 day ago Lower Price Chan(21) < close]

    // for PPO (per cent version of MACD) generally rising

    and [PPO Line(12,26,9) > 20 days ago PPO Line(12,26,9)]
    and [PPO Line(10,26,9) < 0]
    and [10 days ago min(20, PPO Line(12,26,9)) < 25] // or some number
    and [max(15, PPO Line(10,26,9)) > 0]

    Tweaking the parameters will get you different kinds of situations. No one scan is going to get them all. Also, not every hit will be exactly what you want. But it sounds like you probably know that already.
  • Hm I am not looking to use channels for my support break. It should be possible to use the prior low right?

    What I have been trying is to have the prior low defined as something like this:

    6 days ago min(50,low) //the low of the last 50 days from the point of view of 6 days ago (so day 7 to 56 looking back).

    Then I would define the break as:
    min(5,low) < 6 days ago min(50,low) //the low of the last 5 days is lower than the low of the 50 days prior to those 5 days.

    But this does seem to work. What am I doing wrong here?
  • markdmarkd mod
    edited March 2015
    well, you have to make things equal to something

    so for the first part, I think you want to say (I'm omitting syntax)

    6 days ago low = min(50, low)

    in other words, the low 6 days ago is the lowest low for the 50 days prior to that 6 days ago low

    then I think you want to say

    6 days ago low x low -

    in other words, today's low is the first low to break the six days ago low

    and then, close > 6 days ago low


    Or, do you want no gap between the lows? Do you have a chart example?
  • I have added a chart of a classic example of what I want to scan for.
  • OK. Not sure why you wouldn't want to use a channel. They key off the extreme low or high. You just have to settle on the channel length - maybe 50 or 60 instead of 21. Your example is a lower channel break, plus a couple of bars.

    If you don't want the exact break of the channel, write the scan so the break happens 1 or 2 or however many days ago (you could adjust the code above), and then check for the low below yesterday's low and close above yesterday's low.

    You could also check that the channel is lower than some period longer than the channel - say 100 days - that gets you the down trend in that time frame. Or just test for a declining MA - say MA63 < 20 days ago MA63.

    Does that work?
  • To be honest I don't understand the channel you refer to. On this chart there is also a channel (based on the 13EMA). It moves down along with price, which is not what I want. I want it to be a horizontal break of the low. Are you talkin about a raff regression? Wouldn't that put the channel on the latest decline insteado f on the prior one?
  • Sorry, forgot how many kinds of channels there are. These are Price Channels.
    To put them on your chart, go to the chart workbench, click the Overlay drop down. Price Channels is located a few up from the bottom. The default is 20 bars, but you could change that to 50 or 60 for your purposes.

    Then to scan for Price Channels, on the scan workbench, find the Technical Indicators drop down. A little more than half way down you will find Upper Price Chan, Middle Price Chan and Lower Price Chan. They are grouped together with Upper MA Env and Upper Kelt Chan.
  • So basically it will take the high from the last 20 days and put the upper channel line at that level? And put the lower channel at the low of the last 20 days? Not including the current day low (it will be used for the next bar)?
  • Essentially, that's right. It's worth reading the chart school article, if you haven't already:

    stockcharts.com/school/doku.php?id=chart_school:technical_indicators:price_channels

Sign In or Register to comment.