♥ 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
|
Private answer
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:
(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:
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:
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
|
Please log in to post questions.