ProRealCode - Trading & Coding with ProRealTime™
Updates to Violets’ “Trend Reversal and Continuation Patterns:” https://www.prorealcode.com/prorealtime-market-screeners/trend-reversal-continuation-patterns/
For the Morning Star pattern I have striked out the trend filter to highlight the effect that the trend mode can have (in that it can result in patterns not being produced on chart).
Bulkowski Performance Statistics for each of the 8 Patterns in the Indicator (and more) : https://www.dropbox.com/s/0gq5ypd6gwc3h7e/Bulkowski%20-%20PERFORMANCE%20RANKINGS%20-%20Encyclopedia-of-Candlestick-Charts.pdf?dl=0
In the case of the very rare and highest probability pattern, the Bearish Three Line Strike Up, it actually produced a 683 times initial risk per/ tick return in Canadian Pacific Railways (US) Ltd that I traded as an experiment of the patterns behaviour. “Beginners” luck, lol…
// 8 High Probability Bulkowski Candlestick Patterns
//
// The 8 most powerful classical Candlestick Patterns
// Trend reversal and continuation patterns
// Coded by Violet/Additions by Bard
// 4-12-2017 / 23/03/2019
//
// Based on the work of Thomas Bulkowski in his book: "Encyclopedia of Candlestick Charts", 2008
// Read a summary here: https://www.investopedia.com/articles/active-trading/092315/5-most-powerful-candlestick-patterns.asp
//
// This *market-wide screener* works along similar lines as this *fund-specific indicator* in the PRC library list: "Candlestick patterns recognition"
//text color
r = 255
g = 51
b = 51
// DrawText
offset1 = 50 * pipsize
offset2 = offset1 * 6
// Trend direction identification
//(choose 0=No Trend check, 1=MACD, 2=SAR[default], 3=Directional Movement, 4=Moving Averagea crossing)
TDS=3
//Trend Detection
if TDS=0 then
TrendUp=3
TrendDown=3
else
if TDS=1 then
TrendUp=(MACDline[12,26,9](close)>0 AND MACD[12,26,9](close)>0)
TrendDown=(MACDline[12,26,9](close)<0 AND MACD[12,26,9](close)<0)
else
if TDS=2 then
TrendUp=(SAR[0.02,0.02,0.2]<low)
TrendDown=(SAR[0.02,0.02,0.2]>high)
else
if TDS=3 then
TrendUp=(ADX[30]>25 AND DI[30](close)>0) //Default =[14] & >23
TrendDown=(ADX[30]>25 AND DI[30](close)<0)
else
if TDS=4 then
TrendUp=(Average[3](close)>Average[12](close))
TrendDown=(Average[3](close)<Average[12](close))
endif
endif
endif
endif
endif
//
// Signal codes and pattern types
//**************************************************************************
// Name of pattern Type Direction Accuracy rate Bulkowski's Occurrence
//
// ------- ------------ ------------ ----------
// 1 = BearishThreeLineStrikeUp Bullish Reversal 84% Bull Mkt/77% Bear Mkt truly rare
// 2 = BullishThreeLineStrikeDown Bearish Reversal 65% Bull Mkt/83% Bear Mkt truly rare
// 3 = TwoBlackGappingDown Bearish Continuation 68% Bull Mkt/69% Bear Mkt common
// 4 = ThreeBlackCrows Bearish Continuation 78% Bull Mkt/79% Bear Mkt abody
// 5 = MorningStar Bullish Reversal 78% Bull Mkt/65% Bear Mkt very low
// 6 = EveningStar Bearish Reversal 72% Bull Mkt/72% Bear Mkt very low
// 7 = AbandonedBabyBull Bullish Reversal 70% Bull Mkt/55% Bear Mkt low
// 8 = AbandonedBabyBear Bearish Reversal 69% Bull Mkt/52% Bear Mkt Bull Continuation low low//**************************************************************************
//
BearishThreeLineStrikeUp = 0
BullishThreeLineStrikeDown = 0
TwoBlackGappingDown = 0
ThreeBlackCrows = 0
MorningStar = 0
EveningStar = 0
AbandonedBabyBull = 0
AbandonedBabyBear = 0
signal = 0
//Best Probability in Bull Markets
// 1 - (Three Bears then Up) Bearish Three Line Strike Up *************************************
// Bulkowski accuracy rate 84% in Bull Mkt, 77% in a Bear Mkt, frequency: very rare
t1 = close[3] < open[3] // candle 4 = red candle
t2 = close[2] < open[2] and low[2] < low[3] and open[2] < open[3] // candle 3 = red candle, lower low & open than previous candle
t3 = close[1] < open[1] and low[1] < low[2] and open[1] < open[2] // candle 2 = red candle and lower low & open than previous candle
t4 = open[0] < low[1] and close[0] > open[3] // candle 1 = green candle, opens lower than previous candle and closes above open of 4th candle. The candle engulfs the bodies of the three preceding black candles
if TrendDown[3] AND t1 and t2 and t3 and t4 then
BearishThreeLineStrikeUp = 1
endif
if TrendUp[3] AND t1 and t2 and t3 and t4 then
BearishThreeLineStrikeUp = 1
endif
if TrendDown[3] AND t1 and t2 and t3 and t4 then
DRAWTEXT("Bearish Three Line Strike Up", barindex,low-offset2, Dialog, Standard, 20) COLOURED(R,G,B)
DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10)
endif
if TrendUp[3] AND t1 and t2 and t3 and t4 then
DRAWTEXT("Bearish Three Line Strike Up", barindex, high, Dialog, Standard, 20) COLOURED(R,G,B)
DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10)
endif
// 5 Morning Star **************************************************
// Bullish reversal of the downward price trend 78% of the (in a longer term up trend). 65% in a Bear Mkt. Size of price move better in downtrends if time limit of 10 days otherwise uptrends that are left to run are better. Ranked 6th for performance.
//Bearish Pinbar
bearishbody = ABS(open-close)
bearishwick = ABS(high-close)
//bearishnose = ABS(close-low)
Body = abs(close - open) //definition of body
RangeSize = average[50,0](range) //average of the range size of the last 50 candles
LongCandle = Body > (RangeSize * 0.9) //LongCandle is true if the size exceeds a percentage of the average RangeSize
LongCandle2 = Body > (RangeSize * 0.6) //LongCandle is true if the size exceeds a percentage of the average RangeSize
e1 = close[2] < open[2] AND LongCandle // red candle
e2 = open[1] < close[2] and close[1] < close[2] and low[1] < close[2] // candle entirely below predecessor’s body
e3 = close[0] > open[0] and open[0] > open[1] and low[0] < high[1] and LongCandle2 // green candle with a gap
e4 = range[1] < (range[2] / 2 ) // morning star’s range is small compared to preceding candle
e5 = bearishwick/bearishbody < 30/100 // Small Bullish Pinbar/No exhaustion
if e1 and e2 and e3 and e4 and e5 then
MorningStar = 1 //TrendDown[3] AND
endif
if TrendUp[3] AND e1 and e2 and e3 and e4 and e5 then
MorningStar = 1
endif
if e1 and e2 and e3 and e4 then //TrendDown[3] AND
DRAWTEXT("Morning Star", barindex,low-offset2, Dialog, Standard, 20) COLOURED(R,G,B)
DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10)
endif
if TrendUp[3] AND e1 and e2 and e3 and e4 then
DRAWTEXT("Morning Star", barindex,low-offset2, Dialog, Standard, 20) COLOURED(R,G,B)
DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10)
endif
// 7 - Abandoned baby, Bullish Reversal aka Morning Star but with the flatline of a doji ***********************
// Bulkowski accuracy rate 70%, 55% in a Bear Mkt, frequency: low
a1 = high[1] < low[2] // gap
a2 = high[1] < low[0] // gap
a3 = abs(open[1]-close[1]) < ( range[1] / 2 ) // doji like
if TrendDown[3] AND a1 and a2 and a3 then
AbandonedBabyBull = 1
endif
if TrendDown[3] AND a1 and a2 and a3 then
DRAWTEXT("Abandoned Baby Bull", barindex,low-offset2, Dialog, Standard, 20) COLOURED(R,G,B)
DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10)
endif
//Best Probability in Bear Markets
// 2 - (Three Bulls then Down) Bullish Three Line Strike Down *************************************
// Bulkowski accuracy rate - bearish reversal 65% of the time in Bull and 83% in Bear, frequency: very rare
t1 = close[3] > open[3] // candle 4 = green candle
t2 = close[2] > open[2] and high[2] > high[3] and open[2] > open[3] // candle 3 = green candle, higher low & open than previous candle
t3 = close[1] > open[1] and high[1] > high[2] and open[1] > open[2] // candle 2 = green candle and higher low & open than previous candle
t4 = open[0] > low[1] and close[0] < open[3] // candle 1 = red candle, opens higher than previous candle and closes below open of 4th candle. The candle engulfs the bodies of the three preceding green candles
if TrendUp[3] AND t1 and t2 and t3 and t4 then
BullishThreeLineStrikeDown = 1
endif
if TrendDown[3] AND t1 and t2 and t3 and t4 then
BullishThreeLineStrikeDown = 1
endif
if TrendUp[3] AND t1 and t2 and t3 and t4 then
DRAWTEXT("Bullish Three Line Strike Down", barindex,low-offset2, Dialog, Standard, 20) COLOURED(R,G,B)
DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10)
endif
if TrendDown[3] AND t1 and t2 and t3 and t4 then
DRAWTEXT("Bullish Three Line Strike Down", barindex, high, Dialog, Standard, 20) COLOURED(R,G,B)
DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10)
endif
// 3 - Bearish Two Black Gapping *************************
// Bulkowski accuracy rate 69% in Bear Mkt, 68% in Bull Mkt, frequency: common
b1 = close[1] < open[1] // red candle
b2 = close[0] < open[0] // followed by another red candle
b3 = high[0] < low[1] // with a down gap in between
if TrendUp[3] AND b1 and b2 and b3 then
TwoBlackGappingDown = 1
endif
if TrendDown[3] AND b1 and b2 and b3 then
TwoBlackGappingDown = 1
endif
if TrendUp[3] AND b1 and b2 and b3 then
DRAWTEXT("Two Black Gapping Down", barindex,low-offset2, Dialog, Standard, 20) COLOURED(R,G,B)
DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10)
endif
if TrendDown[3] AND b1 and b2 and b3 then
DRAWTEXT("Two Black Gapping Down", barindex,low-offset2, Dialog, Standard, 20) COLOURED(R,G,B)
DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10)
endif
// 4 - Three Black Crows *********************************
// Bulkowski accuracy rate 78% in Bull Mkt, 79% Bear Mkt frequency: very common
c1 = close[2] < open[2]
c2 = close[1] < open[1] and close[1] < low[2]
c3 = close[0] < open[0] and close[0] < low[1]
// Closing prices are less than 1/3 from lows
c4 = abs(close[2] -low[2]) < range[2] / 3
c5 = abs(close[1] -low[1]) < range[1] / 3
c6 = abs(close[0] -low[0]) < range[0] / 3
if c1 and c2 and c3 and c4 and c5 and c6 then
ThreeBlackCrows = 1 //TrendDown[3] AND
endif
if c1 and c2 and c3 and c4 and c5 and c6 then
ThreeBlackCrows = 1 //TrendUp[3] AND
endif
if c1 and c2 and c3 then
DRAWTEXT("Three Black Crows", barindex,low-offset2, Dialog, Standard, 20) COLOURED(R,G,B)
DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10) //TrendUp[3] AND
endif
if c1 and c2 and c3 then
DRAWTEXT("Three Black Crows", barindex,low-offset2, Dialog, Standard, 20) COLOURED(R,G,B)
DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10) // TrendDown[3] AND
endif
// 6 Evening Star **************************************************
// Bulkowski accuracy rate 72% in Bull and 72% Bear Mkt, frequency low
e1 = close[2] > open[2] // green candle
e2 = open[1] > close[2] and close[1] > close[2] and low[1] > close[2] // candle entirely above predecessor's body
e3 = close[0] < open[0] and high[0] < low[1] // red candle with a gap
e4 = range[1] < (range[2] / 2 ) // evening star's range is small compared to preceding candle
if TrendDown[3] AND e1 and e2 and e3 and e4 then
EveningStar = 1
endif
if TrendUp[3] AND e1 and e2 and e3 and e4 then
EveningStar = 1
endif
if TrendUp[3] AND e1 and e2 and e3 then
DRAWTEXT("Evening Star", barindex,low-offset2, Dialog, Standard, 20) COLOURED(R,G,B)
DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10)
endif
if TrendDown[3] AND e1 and e2 and e3 then
DRAWTEXT("Evening Star", barindex,low-offset2, Dialog, Standard, 20) COLOURED(R,G,B)
DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10)
endif
// 8 - Abandoned baby, Bearish Reversal aka Evening Star but with the flatline of a doji. Trend doesn't last long ***********************
// Bulkowski accuracy rate in Bull Mkt 69%, 52% in a Bear Mkt, frequency: low
a1 = close[2] > open[2] // green candle
a2 = open[1] > close[2] and close[1] > close[2] and low[1] > high[2] // candle entirely above predecessor's body
a3 = close[0] < open[0] and low[1] > high[0] // red candle with a gap
a4 = range[1] > (range[2] / 16 ) // range is small compared to preceding candle // Default (range[2] / 8 )
if TrendDown[3] AND a1 and a2 and a3 and a4 then
AbandonedBabyBear = 1
endif
if TrendDown[3] AND a1 and a2 and a3 then
DRAWTEXT("Abandoned Baby Bear", barindex,low-offset2, Dialog, Standard, 20) COLOURED(R,G,B)
DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10)
endif
// Results ******************
if BearishThreeLineStrikeUp then
signal = 1
elsif BullishThreeLineStrikeDown then
signal = 2
elsif TwoBlackGappingDown then
signal = 3
elsif ThreeBlackCrows then
signal = 4
elsif MorningStar then
signal = 5
elsif EveningStar then
signal = 6
elsif AbandonedBabyBull then
signal = 7
elsif AbandonedBabyBear then
signal = 8
endif
//
// Pattern types
//**************************
//Type = Name of pattern
//---- -------------------
// 1 = BearishThreeLineStrikeUp
// 2 = BullishThreeLineStrikeDown
// 3 = TwoBlackGappingDown
// 4 = ThreeBlackCrows
// 5 = MorningStar
// 6 = EveningStar
// 7 = AbandonedBabyBull
// 8 = AbandonedBabyBear
//**************************
//
Return signal > 0
More Candlestick Detection here using Top Movers:
A few observations since posting earlier:
A few small errors have been fixed like making sure all the a1, a2’s have been utilised in the Draw Text code.
I’m not sure the effect of have two sets of a1= etc and a2= etc, and t1= t2= etc overlapping conditions for two different patterns (Abandoned Baby’s and Three Line Strikes) both patterns appear on chart (and when applied as a separate indicator below the price chart) but I have reposted the amended code below with different conditional letters.
I think it’s better to strike out // the Trend Rules to produce more patterns and you can use your own judgement as to the direction of trend. I’ve left the Trend code in with strikes.
Note: 7. Abandoned Baby had two x TrendDown’s.
The Morning Star rules can be relaxed as I see in my code I included a more extreme LongCandle = Body > (RangeSize * 0.9) when I was testing it.
0.7 is fine.
Another addition has been added (that I spotted from my Dropbox pdf link) : Three White Soldiers.
It has strong directional probabilities although performance isn’t always strong post pattern.. better for Scalpers.
(Note: In the Top Movers Screener there are Candlestick pattern and you can set the “Criteria” from “Completed” to “Current.” I can’t vouch for their accuracy in construction/coding or Bulkowski’s performance statistics).
Bulkowski’s Candlestick Descriptions and Performance Statistics can be found on his site:
// 9 High Probability Bulkowski Candlestick Patterns
//
// The 9 most powerful classical Candlestick Patterns
// Trend reversal and continuation patterns
// Coded by Violet/Additions by Bard
// 4-12-2017 /23/03/2019
//
// Based on the work of Thomas Bulkowski in his book: "Encyclopedia of Candlestick Charts", 2008
// Read a summary here: https://www.investopedia.com/articles/active-trading/092315/5-most-powerful-candlestick-patterns.asp
//
// This *market-wide screener* works along similar lines as this *fund-specific indicator* in the PRC library list: "Candlestick patterns recognition"
//text color
r = 255
g = 51
b = 51
// DrawText
offset1 = 50 * pipsize
offset2 = offset1 * 6
// Trend direction identification
//(choose 0=No Trend check, 1=MACD, 2=SAR[default], 3=Directional Movement, 4=Moving Averagea crossing)
//TDS=3
//Trend Detection
//if TDS=0 then
//TrendUp=3
//TrendDown=3
//else
//if TDS=1 then
//TrendUp=(MACDline[12,26,9](close)>0 AND MACD[12,26,9](close)>0)
//TrendDown=(MACDline[12,26,9](close)<0 AND MACD[12,26,9](close)<0)
//else
//if TDS=2 then
//TrendUp=(SAR[0.02,0.02,0.2]<low)
//TrendDown=(SAR[0.02,0.02,0.2]>high)
//else
//if TDS=3 then
//TrendUp=(ADX[30]>25 AND DI[30](close)>0) //Default =[14] & >23
//TrendDown=(ADX[30]>25 AND DI[30](close)<0)
//else
//if TDS=4 then
//TrendUp=(Average[3](close)>Average[12](close))
//TrendDown=(Average[3](close)<Average[12](close))
//endif
//endif
//endif
//endif
//endif
//
// Signal codes and pattern types
//**************************************************************************
// Name of pattern Type Direction Accuracy rate Bulkowski's Occurrence
//
// ------- ------------ ------------ ----------
// 1 = BearishThreeLineStrikeUp Bullish Reversal 84% Bull Mkt/77% Bear Mkt truly rare
// 2 = BullishThreeLineStrikeDown Bearish Reversal 65% Bull Mkt/83% Bear Mkt truly rare
// 3 = TwoBlackGappingDown Bearish Continuation 68% Bull Mkt/69% Bear Mkt common
// 4 = ThreeBlackCrows Bearish Continuation 78% Bull Mkt/79% Bear Mkt abody
// 5 = MorningStar Bullish Reversal 78% Bull Mkt/65% Bear Mkt very low
// 6 = EveningStar Bearish Reversal 72% Bull Mkt/72% Bear Mkt very low
// 7 = AbandonedBabyBull Bullish Reversal 70% Bull Mkt/55% Bear Mkt low
// 8 = AbandonedBabyBear Bearish Reversal 69% Bull Mkt/52% Bear Mkt Bull Continuation low low
// 9 = Three White Soldiers Bullish Reversal 82% Bull Mkt/84% Bear Mkt low
//**************************************************************************
//
BearishThreeLineStrikeUp = 0 //(s)
BullishThreeLineStrikeDown = 0 //(t)
TwoBlackGappingDown = 0 //(b)
ThreeBlackCrows = 0 //(c)
MorningStar = 0 //(m)
EveningStar = 0 //(e)
AbandonedBabyBull = 0 //(d)
AbandonedBabyBear = 0 //(a)
ThreeWhiteSoldiers = 0 //(w)
signal = 0
//Best Probability in Bull Markets
// 1 - (Three Bears then Up) Bearish Three Line Strike Up *************************************
// Bulkowski accuracy rate 84% in Bull Mkt, 77% in a Bear Mkt, frequency: very rare
s1 = close[3] < open[3] // candle 4 = red candle
s2 = close[2] < open[2] and low[2] < low[3] and open[2] < open[3] // candle 3 = red candle, lower low & open than previous candle
s3 = close[1] < open[1] and low[1] < low[2] and open[1] < open[2] // candle 2 = red candle and lower low & open than previous candle
s4 = open[0] < low[1] and close[0] > open[3] // candle 1 = green candle, opens lower than previous candle and closes above open of 4th candle. The candle engulfs the bodies of the three preceding black candles
//if s1 and s2 and s3 and s4 then //TrendDown[3] AND
////BearishThreeLineStrikeUp = 1
//endif
if s1 and s2 and s3 and s4 then //TrendUp[3] AND
BearishThreeLineStrikeUp = 1
endif
if s1 and s2 and s3 and s4 then //TrendDown[3] AND
DRAWTEXT("Bearish Three Line Strike Up", barindex,low-offset2, Dialog, Standard, 20) COLOURED(R,G,B)
DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10)
endif
//if s1 and s2 and s3 and s4 then //TrendUp[3] AND
//DRAWTEXT("Bearish Three Line Strike Up", barindex, high, Dialog, Standard, 20) COLOURED(R,G,B)
//DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10)
//endif
// 5 Morning Star **************************************************
// Bullish reversal of the downward price trend 78% of the (in a longer term up trend). 65% in a Bear Mkt. Size of price move better in downtrends if time limit of 10 days otherwise uptrends that are left to run are better. Ranked 6th for performance.
//Bearish Pinbar
bearishbody = ABS(open-close)
bearishwick = ABS(high-close)
//bearishnose = ABS(close-low)
Body = abs(close - open) //definition of body
RangeSize = average[50,0](range) //average of the range size of the last 50 candles
LongCandle = Body > (RangeSize * 0.9) //LongCandle is true if the size exceeds a percentage of the average RangeSize
LongCandle2 = Body > (RangeSize * 0.6) //LongCandle is true if the size exceeds a percentage of the average RangeSize
m1 = close[2] < open[2] AND LongCandle // red candle
m2 = open[1] < close[2] and close[1] < close[2] and low[1] < close[2] // candle entirely below predecessor’s body
m3 = close[0] > open[0] and open[0] > open[1] and low[0] < high[1] and LongCandle2 // green candle with a gap
m4 = range[1] < (range[2] / 2 ) // morning star’s range is small compared to preceding candle
m5 = bearishwick/bearishbody < 30/100 // Small Bullish Pinbar/No exhaustion
if m1 and m2 and m3 and m4 and m5 then //TrendDown[3] AND
MorningStar = 1
endif
//if m1 and m2 and m3 and m4 and m5 then //TrendUp[3] AND
//MorningStar = 1
//endif
if m1 and m2 and m3 and m4 and m5 then //TrendDown[3] AND
DRAWTEXT("Morning Star", barindex,low-offset2, Dialog, Standard, 20) COLOURED(R,G,B)
DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10)
endif
//if m1 and m2 and m3 and m4 and m5 then //TrendUp[3] AND
//DRAWTEXT("Morning Star", barindex,low-offset2, Dialog, Standard, 20) COLOURED(R,G,B)
//DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10)
//endif
// 7 - Abandoned baby, Bullish Reversal aka Morning Star but without the flatline of a doji ***********************
// Bulkowski accuracy rate 70%, 55% in a Bear Mkt, frequency: low
d1 = close[2] < open[2] // red candle
d2 = open[1] < close[2] and close[1] < close[2] and high[1] < low[2] // candle entirely below predecessor's body
d3 = close[0] > open[0] and low[0] > high[1] // green candle with a gap
d4 = range[1] > (range[2] / 16 ) // morning star's range is small compared to preceding candle // Default (range[2] / 8 )
if d1 and d2 and d3 and d4 then //TrendDown[3] AND
AbandonedBabyBull = 1
endif
if d1 and d2 and d3 and d4 then //TrendDown[3] AND
DRAWTEXT("Abandoned Baby Bull", barindex,low-offset2, Dialog, Standard, 20) COLOURED(R,G,B)
DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10)
endif
//Best Probability in Bear Markets
// 2 - (Three Bulls then Down) Bullish Three Line Strike Down *************************************
// Bulkowski accuracy rate - bearish reversal 65% of the time in Bull and 83% in Bear, frequency: very rare
t1 = close[3] > open[3] // candle 4 = green candle
t2 = close[2] > open[2] and high[2] > high[3] and open[2] > open[3] // candle 3 = green candle, higher low & open than previous candle
t3 = close[1] > open[1] and high[1] > high[2] and open[1] > open[2] // candle 2 = green candle and higher low & open than previous candle
t4 = open[0] > low[1] and close[0] < open[3] // candle 1 = red candle, opens higher than previous candle and closes below open of 4th candle. The candle engulfs the bodies of the three preceding green candles
//if t1 and t2 and t3 and t4 then //TrendUp[3] AND
//BullishThreeLineStrikeDown = 1
//endif
if t1 and t2 and t3 and t4 then //TrendDown[3] AND
BullishThreeLineStrikeDown = 1
endif
if t1 and t2 and t3 and t4 then //TrendUp[3] AND
DRAWTEXT("Bullish Three Line Strike Down", barindex,low-offset2, Dialog, Standard, 20) COLOURED(R,G,B)
DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10)
endif
//if t1 and t2 and t3 and t4 then //TrendDown[3] AND
////DRAWTEXT("Bullish Three Line Strike Down", barindex, high, Dialog, Standard, 20) COLOURED(R,G,B)
//DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10)
//endif
// 3 - Bearish Two Black Gapping *************************
// Bulkowski accuracy rate 69% in Bear Mkt, 68% in Bull Mkt, frequency: common
b1 = close[1] < open[1] // red candle
b2 = close[0] < open[0] // followed by another red candle
b3 = high[0] < low[1] // with a down gap in between
//if b1 and b2 and b3 then //TrendUp[3] AND
//TwoBlackGappingDown = 1
//endif
if b1 and b2 and b3 then //TrendDown[3] AND
TwoBlackGappingDown = 1
endif
//if b1 and b2 and b3 then //TrendUp[3] AND
//DRAWTEXT("Two Black Gapping Down", barindex,low-offset2, Dialog, Standard, 20) COLOURED(R,G,B)
//DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10)
//endif
if b1 and b2 and b3 then //TrendDown[3] AND
DRAWTEXT("Two Black Gapping Down", barindex,low-offset2, Dialog, Standard, 20) COLOURED(R,G,B)
DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10)
endif
// 4 - Three Black Crows *********************************
// Bulkowski accuracy rate 78% in Bull Mkt, 79% Bear Mkt frequency: very common
c1 = close[2] < open[2]
c2 = close[1] < open[1] and close[1] < low[2]
c3 = close[0] < open[0] and close[0] < low[1]
// Closing prices are less than 1/3 from lows
c4 = abs(close[2] -low[2]) < range[2] / 3
c5 = abs(close[1] -low[1]) < range[1] / 3
c6 = abs(close[0] -low[0]) < range[0] / 3
if c1 and c2 and c3 and c4 and c5 and c6 then
ThreeBlackCrows = 1 //TrendDown[3] AND
endif
//if c1 and c2 and c3 and c4 and c5 and c6 then
//ThreeBlackCrows = 1 //TrendUp[3] AND
//endif
//if c1 and c2 and c3 and c4 and c5 and c6 then
//DRAWTEXT("Three Black Crows", barindex,low-offset2, Dialog, Standard, 20) COLOURED(R,G,B)
//DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10) //TrendUp[3] AND
//endif
if c1 and c2 and c3 and c4 and c5 and c6 then
DRAWTEXT("Three Black Crows", barindex,low-offset2, Dialog, Standard, 20) COLOURED(R,G,B)
DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10) // TrendDown[3] AND
endif
// 6 Evening Star **************************************************
// Bulkowski accuracy rate 72% in Bull and 72% Bear Mkt, frequency low
e1 = close[2] > open[2] // green candle
e2 = open[1] > close[2] and close[1] > close[2] and low[1] > close[2] // candle entirely above predecessor's body
e3 = close[0] < open[0] and high[0] < low[1] // red candle with a gap
e4 = range[1] < (range[2] / 2 ) // evening star's range is small compared to preceding candle
if e1 and e2 and e3 and e4 then //TrendDown[3] AND
EveningStar = 1
endif
//if e1 and e2 and e3 and e4 then //TrendUp[3] AND
//endif
//if e1 and e2 and e3 and e4 then //TrendUp[3] AND
//DRAWTEXT("Evening Star", barindex,low-offset2, Dialog, Standard, 20) COLOURED(R,G,B)
//DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10)
//endif
if e1 and e2 and e3 and e4 then //TrendDown[3] AND
DRAWTEXT("Evening Star", barindex,low-offset2, Dialog, Standard, 20) COLOURED(R,G,B)
DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10)
endif
// 8 - Abandoned baby, Bearish Reversal aka Evening Star but with the flatline of a doji. Trend doesn't last long ***********************
// Bulkowski accuracy rate in Bull Mkt 69%, 52% in a Bear Mkt, frequency: low
a1 = close[2] > open[2] // green candle
a2 = open[1] > close[2] and close[1] > close[2] and low[1] > high[2] // candle entirely above predecessor's body
a3 = close[0] < open[0] and low[1] > high[0] // red candle with a gap
a4 = range[1] > (range[2] / 16 ) // range is small compared to preceding candle // Default (range[2] / 8 )
if a1 and a2 and a3 and a4 then //TrendDown[3] AND
AbandonedBabyBear = 1
endif
//if a1 and a2 and a3 and a4 then //TrendUp[3] AND
//DRAWTEXT("Abandoned Baby Bear", barindex,low-offset2, Dialog, Standard, 20) COLOURED(R,G,B)
//DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10)
//endif
// 9 - Three White Soldiers, Bullish Reversal. Price does not trend all that well after the breakout. Performance after formation not strong ***********************
// Bulkowski accuracy rate in Bull Mkt 82%, 84% in a Bear Mkt, frequency: low
body=close-open
w1 = body[2]>0 and body[1]>0 and body>0
w2 = high[1]>high[2] and high>high[1]
w3 = close[1]>close[2] and close>close[1]
w4 = open[1]>open[2] and open[1]<close[2] and open>open[1] and open<close[1]
if w1 and w2 and w3 and w4 then //TrendDown[3] AND
ThreeWhiteSoldiers = 1
endif
if w1 and w2 and w3 and w4 then
DRAWTEXT("Three White Soldiers", barindex,low-offset2, Dialog, Standard, 20) COLOURED(R,G,B)
DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10)
endif
// Results ******************
if BearishThreeLineStrikeUp then
signal = 1
elsif BullishThreeLineStrikeDown then
signal = 2
elsif TwoBlackGappingDown then
signal = 3
elsif ThreeBlackCrows then
signal = 4
elsif MorningStar then
signal = 5
elsif EveningStar then
signal = 6
elsif AbandonedBabyBull then
signal = 7
elsif AbandonedBabyBear then
signal = 8
elsif ThreeWhiteSoldiers then
signal = 9
endif
//
// Pattern types
//**************************
//Type = Name of pattern
//---- -------------------
// 1 = BearishThreeLineStrikeUp
// 2 = BullishThreeLineStrikeDown
// 3 = TwoBlackGappingDown
// 4 = ThreeBlackCrows
// 5 = MorningStar
// 6 = EveningStar
// 7 = AbandonedBabyBull
// 8 = AbandonedBabyBear
// 9 = ThreeWhiteSoldiers
//**************************
//
Return signal > 0
Wow you’ve had a buy weekend Bard …. thank you for sharing your good work!
Cheers
GraHal
Cheers @GraHal, it needed to be done!
I’m still referring to those Dropbox pdf stats above and Bulkowski’s book so I may add some more Higher Probability Patterns later like the Bearish Engulfing (bottom of list) which is a Bearish Reversal 79% of the time in a Bull Market and 82% in a Bear.
Hi Bard,
really good job on this code. I am not a big fan of Bulkowsky to be honest (I am not really sure about he checks facts) but definitely your code is awesome!!
G
Hey, I forgot to add this. Bulkowski also says that “Most of the time, candles that showed the highest post breakout move began their life within the lowest third of the yearly price range. Here are the results.”. In his website he says that 84% of the reverse candles starting in the lowest third of the yearly price range are successful….food for thoughts.
Cheers, appreciated @Gabri, I was thinking along the same lines and making sure I had defined a Bull and Bear Market as per Bulkowski. I also added some moving averages codes and started on a “simple” indicator… lol.. but got stuck with the ALMA moving average programming (not a programmer) but that’s all fixed now thanks to help on this forum from Nicolas and Roberto:
Now another indicator to spot prices in a 1/3 of their yearly highs and lows would be handy too!
Now another indicator to spot prices in a 1/3 of their yearly highs and lows would be handy too!
Try this:
startdate = opendate - 10000
hh = 0
ll = 100000000000
if opendate[barindex] < startdate and not done then
a = barindex
done = 1
endif
if done then
hh = highest[a](high)
ll = lowest[a](low)
lowlevel = ((hh - ll) / 3) + ll
highlevel = hh - ((hh - ll) / 3)
flag = 0
if close < lowlevel then
flag = -1
r = 128
g = 0
endif
if close > highlevel then
flag = 1
r = 0
g = 128
endif
endif
return flag coloured(r,g,0)style(histogram,2) as "Year Range Thirds"
It counts how many bars are in a year by comparing today’s date to the first bar on a chart. Once a year has past it knows how many bars are in a year (so it can be used on any time frame). It then finds the highest high and the lowest low in that number of bars and so can then know what the top 1/3rd level is and the bottom 1/3rd level is.
Not fully tested and written in a hurry!
I first coded the indicator in my last post using for next loops and then while wend loops to get it to accurately only test the highs and lows in exactly the last year but it was incredibly slow to get a result. The version in the last post has the disadvantage that if the first year on a chart is a leap year then the number of bars it uses for all future years will be the number in a leap year but I felt it was accurate enough that the extra speed to calculate overcame the potential for inaccuracy.
Wow, nice going @Vonasi, thanks very much for coding that and thank you @Gabri.
Here is a Dow Chart that now shows another very interesting way of looking at the market. I’d been using Std Deviations, Linear Regression[60], R-Squared and ALMA 200 in blue and also Std Error Bands. But this gives a great indication of risk/returns and strength. I’ve also added the Bull/Bear ALMA indicator in the second image of the last 18 months of turbulence on the Dow. 👌👌
As great as all the ingenuity that goes into these excellent indicators on PRC, remember:
As hunter gatherers our survival depended upon traits that have become hard wired into our DNA. We seized opportunity (food) when it presented itself and as we also stood our ground in adversity.
Both those traits spell disaster for a trader!
Friday evening, philosophical Bard.
8 High Probability Bulkowski Candlestick Patterns
This topic contains 11 replies,
has 5 voices, and was last updated by Bard
6 years, 10 months ago.
| Forum: | ProBuilder: Indicators & Custom Tools |
| Language: | English |
| Started: | 03/23/2019 |
| Status: | Active |
| Attachments: | 4 files |
The information collected on this form is stored in a computer file by ProRealCode to create and access your ProRealCode profile. This data is kept in a secure database for the duration of the member's membership. They will be kept as long as you use our services and will be automatically deleted after 3 years of inactivity. Your personal data is used to create your private profile on ProRealCode. This data is maintained by SAS ProRealCode, 407 rue Freycinet, 59151 Arleux, France. If you subscribe to our newsletters, your email address is provided to our service provider "MailChimp" located in the United States, with whom we have signed a confidentiality agreement. This company is also compliant with the EU/Swiss Privacy Shield, and the GDPR. For any request for correction or deletion concerning your data, you can directly contact the ProRealCode team by email at privacy@prorealcode.com If you would like to lodge a complaint regarding the use of your personal data, you can contact your data protection supervisory authority.