Short side of 3 Bar Pattern Play Scan


Category:
0
0

Hi Pete, thank you for sharing your coding skills on this great site which I came across while doing some research on the 3 bar pattern play.  You previously shared a code to scan for that pattern (see Cutom Scan for the 3 Bar Pattern Play) and I made some modifications to account for a red or green 2nd bar, the maximum decline and increase of the 2nd bar relative to the 1st bar, and minimum volume on the 1st bar.  It seems to work well for all time frames for long positions in up-trending markets and I’ve attached it below.

I’m now trying to figure out how to modify it for taking short positions in down-trending markets.  It seems like I’ve changed the right things but the pattern it finds looks more like the three bar long patterns.  The pattern it should find would be a wide range red first bar on higher volume, then a narrow range second bar of either color on low volume near the low of the first bar with no more than a .618 retracement into the high of the first bar.

I would be more than happy to make a donation for your insight on what I’m doing wrong. 

Thanks so much!

Ed  

Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on February 21, 2020 2:58 pm
239 views
0
Private answer
  1. Always include a direct link to any source that you reference so that the rest of our viewers can follow along and get the full context. (and more importantly the original version)
  2. Make sure the question title is specific. In this case I updated your question title to make sure other viewers are able to distinguish the difference between your post and the original.
  3. Hahn-Tech, LLC is a for profit company and therefore does not accept donations. We do have a method for viewers to make a "voluntary contribution". However this is in no way connected to any of the solutions provided in the Q&A forum. It's simply a tip jar and is only available because years ago someone asked for a way to show their appreciation in monetary terms.

Here is a link to the previous post you mention:

https://www.hahn-tech.com/ans/custom-scan-for-the-3-bar-pattern-play/

And it turns out that even I required that original code to determine where you went wrong. The following line of code is from the example you gave:

def shortCandleTwo = range < range[1] and low <= 1.005 * low[1] and high <= (low[1] - (0.618 * low[1]));

(notice I have made some changes to make the code much easier to read)

Now here is the same line of code from the original:

def shortCandleTwo = close < open and range < range[1] and high <= high[1];

I see that you added some math to this line however you left out one very important detail:

close < open

You also forgot to flip the sign for the portion that checks the low of that candle to it's previous low. In the original we are checking if the high is less than or equal to the bar previous to it. In your code you need to check if the low is GREATER than or equal to the previous low. So here it is, corrected for those two errors:

def shortCandleTwo = close < open and range < range[1] and low >= 1.005 * low[1] and high <= (low[1] - (0.618 * low[1]));

However there is still an error in the math used to check if "...with no more than a .618 retracement into the high of the first bar...". I will leave that to you to work out, now that the most important details have been corrected. You might try leaving that last condition out altogether until you are sure the first parts are working correctly. But I would expect the correct mathematical formula would include the range times 0.618 added to the low. What you have done is to subtract that value from the low, which means instead of a retracement into the range of the previous bar you are forcing it to the below the previous candles range. You see that?

Last item I will leave for you. Always be sure to place spaces in your code between variables and operators (operators are +, -, /, *). The way you had it written makes it extremely difficult to read when viewing the code in a plan text file.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on February 22, 2020 8:13 am
0
Wow Pete, thank you for the super quick reply and for the detailed answers which seem so embarrassingly obvious now. I like trying to figure these things out but, as Clint Eastwood said, "A man's got to know his limitations." I purposely left out the close < open because I don't care what color the second candle is. Am I correct in assuming that leaving it out will have the intended effect? I'll make your other corrections and will let you know how it goes and will make sure to properly space in future posts. Kind regards, Ed
( at February 22, 2020 9:01 am)
0
Ok, yes. Leaving out the close < open will permit that second candle to be red or green and not impact the rest of the pattern.
( at February 22, 2020 11:29 am)