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.

Specific Candlestick Scan

I have been looking all over stockcharts website and here on the forums on how to build a specific candlestick scan. I did a google search and even emailed support with no luck. I did find a DIY sample for a gravestone doji but I just can't figure out how to make it what I want. I hope someone can help me out here.

I am trying to do a scan for a candlestick that Martha Stokes calls "the dragon" and "reverse dragon". It seems simple enough but I just can't seem to get the right syntax. Basically they are a hammer or reverse hammer, except that the tail on the hammer is at least 3 times the length of the body (close-open * 3 on up day or open - close * 3 on down day) with a small to no wick. The body must be small but no reference as to how small. It can be either an up day(green candle) or down day(red candle) And, of course, the reverse dragon is just the opposite. I am currently using a work around by scanning for hammers and dragonfly doji for the dragon and gravstone doji and shooting star for reverse dragon's.

Here is what I found on the gravestone doji:

Do-It-Yourself Gravestone Doji
Charts with a gravestone doji for today's candlestick:

[type = stock]
and [open = close]
and [open = low]
and [high> open * 1.05]
Notes: This looks for candles with a 5% or more upper shadow. You can change '1.05' to suit your trading style.

What I need to do is open up the open and close to accommodate the small body while also accommodating the up or down candle. How would I do that?
And, again, I'm not sure how small the body must be, but maybe similar to a hammer. Also, I'm not sure how to accommodate a little to no wick parameter.
Would I have to make this into two parameters, one for an up candle and one for a down candle or can it be combined for both up and down?
Any help would be greatly appreciated.

Best Answer

  • markdmarkd mod
    Answer ✓
    You can express the difference between the open and close as a per cent of range:

    // close is above the open
    and [close > open]

    // body is less than x per cent of range
    and [close - open < range * .01]

    For ".01", substitute whatever works - maybe .001 or .10 or something in between.

    If the close is below the open, you would reverse the positions of "close" and "open" in these statements to keep the numbers positive. (Unfortunately, you can't do calculations inside the "absval()" function - it only converts negative indicator values to positive.)

    For the wick parameter, you could do something similar - express the difference between the close and the high as less than some small per cent of range. That ensures the close is near the high. If you want the close near the low, then do the same with the difference between the close and the low.

    You may also want to insure some minimum range, like

    and [range > ATR(21) * .8]

    or something similar.

    To avoid confusion, you should first write separate scans looking for just one type of bar. Then, if you think it's a good idea, you could combine them, probably with one or more "or" statements.

Answers

  • Thanks markd for the reply. So I was playing around with it and came up with this.

    [type = stock] and [exchange is NYSE] or [exchange is NASDAQ] or [exchange is AMEX]
    and [[close > open] and [close - open < range * .30] and [high - close < range * .05] and [open - low >= 1.30] or [open > close] and [open - close < range * .30] and [high - open < range * .05] and [close - low > 1.30]]
    rank by [PctChange(1, close)]

    This is the exact scan that I used and it pulled up only 11 stocks so it may need some more work as this scan doesn't include average volume and price that I trade, nor does it include where in the trend it should be. With such general parameters I thought it would have pulled up more. But the candles that it brought up is exactly what I am looking for.

    I didn't use "and [range > ATR(21) * .8]" because I don't quite understand what that is looking for. I know ATR is Average True Range but I'm just not sure what, exactly, that parameter is looking for and how it would fit in with the candlestick.

    If you have any other advice to make it better I'd be glad to hear it. Thanks for the help so far, I appreciate it.
  • Ok, so after playing around some more I decided to separate the up day and down day and found that they were pulling up a few more stocks separated than they were together. So now I'll need to figure out why.

    So now I have an upday that looks like this:

    [type = stock] and [exchange is NYSE] or [exchange is NASDAQ] or [exchange is AMEX]
    and [close > open] and [close - open < range * .30] and [high - close < range * .05] and [open - low >= 1.30]
    rank by [PctChange(1, close)]

    This one pulled up 13 stocks.

    and a downday that looks like this:

    [type = stock] and [exchange is NYSE] or [exchange is NASDAQ] or [exchange is AMEX]
    and [open > close] and [open - close < range * .30] and [high - open < range * .05] and [close - low >= 1.30]
    rank by [PctChange(1, close)]

    This one pulled up 8 stocks. These were all different stocks. But when the scans were combined like this:

    [type = stock] and [exchange is NYSE] or [exchange is NASDAQ] or [exchange is AMEX]
    and [[close > open] and [close - open < range * .30] and [high - close < range * .05] and [open - low >= 1.30] or [open > close] and [open - close < range * .30] and [high - open < range * .05] and [close - low >= 1.30]]
    rank by [PctChange(1, close)]

    it pulled up 11 stocks, all 8 of the downday stocks and only 3 of the upday stocks. Any idea why that would happen? By the way, these scans are for bullish signals.

    I also built scans for the bearish signals and I'm getting 5 stocks on the upday and 3 on the downday with 3 on the combined that matches the downday but none of the upday stocks are on the combined scan. Here are the bearish scans:

    Upday

    [type = stock] and [exchange is NYSE] or [exchange is NASDAQ] or [exchange is AMEX]
    and [close > open] and [close - open < range * .30] and [open - low < range * .05] and [high - close >= 1.30]
    rank by Ascending [PctChange(1, close)]

    Downday

    [type = stock] and [exchange is NYSE] or [exchange is NASDAQ] or [exchange is AMEX]
    and [open > close] and [open - close < range * .30] and [close - low < range * .05] and [high - open >= 1.30]
    rank by Ascending [PctChange(1, close)]


    and combined

    [type = stock] and [exchange is NYSE] or [exchange is NASDAQ] or [exchange is AMEX]
    and [[close > open] and [close - open < range * .30] and [open - low < range * .05] and [high - close >= 1.30] or [open > close] and [open - close < range * .30] and [close - low < range * .05] and [high - open >=1.30]]
    rank by Ascending [PctChange(1, close)]

    I'm not sure where the problem is unless I am not combining them correctly. I used the "or" clause and put extra brackets on each end. I think that is the way it's supposed to be done. I hope you have a chance to look over at least one of them and tell me what you think. Thanks for the help if you have time.

  • I made a couple of changes to the "up day" scan. I got about 50 hits. Note - this does not ask for an "up day" because there is no line asking for close > 1 day ago close. It only asks for close above open. If the open is way down, you can still get a close above the open but below yesterday's close.

    [type = stock]

    and [ [exchange is NYSE] or [exchange is NASDAQ] or [exchange is AMEX] ]

    and [close > open]
    and [close - open < range * .30]
    and [open - low < range * .05]
    and [range > ATR(21) * .8]

    //and [high - close >= 1.30]
    //rank by Ascending [PctChange(1, close)]

    As you can see, I bracketed the "or" statements around your exchange conditions. This is a good practice to follow to be sure you get what you think you are asking for.

    I commented out the "high - close..." line and substituted the "range > ATR..." line.

    The "high - close..." line asks for a candle that is more than 1.3 POINTS wide. This is a specific distance. Many stocks trade over less than a full point range in one bar. What you want is a ratio of the body to the entire range.

    ATR(21) measures the average range of the last 21 candles. ATR(21) * .8 means you want to look at candles that are at least 80 per cent as tall as the average candle for the last month. That eliminates very short candles that probably are not what Martha is talking about.
Sign In or Register to comment.