Patterns is a Japanese candlestick pattern recognition Library for developers. Functions here within detect viable setups in a variety of popular patterns. Please note some patterns are without filters such as comparisons to average candle sizing, or trend detection to allow the author more freedom.
doji(dojiSize, dojiWickSize) Detects "Doji" candle patterns Parameters: dojiSize: (float) The relationship of body to candle size (ie. body is 5% of total candle size). Default is 5.0 (5%) dojiWickSize: (float) Maximum wick size comparative to the opposite wick. (eg. 2 = bottom wick must be less than or equal to 2x the top wick). Default is 2 Returns: (series bool) True when pattern detected
dLab(showLabel, labelColor, textColor) Produces "Doji" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
bullEngulf(maxRejectWick, mustEngulfWick) Detects "Bullish Engulfing" candle patterns Parameters: maxRejectWick: (float) Maximum rejection wick size. The maximum wick size as a percentge of body size allowable for a top wick on the resolution candle of the pattern. 0.0 disables the filter. eg. 50 allows a top wick half the size of the body. Default is 0% (Disables wick detection). mustEngulfWick: (bool) input to only detect setups that close above the high prior effectively engulfing the candle in its entirety. Default is false Returns: (series bool) True when pattern detected
bewLab(showLabel, labelColor, textColor) Produces "Bullish Engulfing" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
bearEngulf(maxRejectWick, mustEngulfWick) Detects "Bearish Engulfing" candle patterns Parameters: maxRejectWick: (float) Maximum rejection wick size. The maximum wick size as a percentge of body size allowable for a bottom wick on the resolution candle of the pattern. 0.0 disables the filter. eg. 50 allows a botom wick half the size of the body. Default is 0% (Disables wick detection). mustEngulfWick: (bool) Input to only detect setups that close below the low prior effectively engulfing the candle in its entirety. Default is false Returns: (series bool) True when pattern detected
bebLab(showLabel, labelColor, textColor) Produces "Bearish Engulfing" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
hammer(ratio, shadowPercent) Detects "Hammer" candle patterns Parameters: ratio: (float) The relationship of body to candle size (ie. body is 33% of total candle size). Default is 33%. shadowPercent: (float) The maximum allowable top wick size as a percentage of body size. Default is 5%. Returns: (series bool) True when pattern detected
hLab(showLabel, labelColor, textColor) Produces "Hammer" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
star(ratio, shadowPercent) Detects "Star" candle patterns Parameters: ratio: (float) The relationship of body to candle size (ie. body is 33% of total candle size). Default is 33%. shadowPercent: (float) The maximum allowable bottom wick size as a percentage of body size. Default is 5%. Returns: (series bool) True when pattern detected
ssLab(showLabel, labelColor, textColor) Produces "Star" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
ddLab(showLabel, labelColor) Produces "Dragonfly Doji" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow Returns: (series label) A label visible at the chart level intended for the title pattern
gdLab(showLabel, labelColor, textColor) Produces "Gravestone Doji" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
tweezerBottom(closeUpperHalf) Detects "Tweezer Bottom" candle patterns Parameters: closeUpperHalf: (bool) input to only detect setups that close above the mid-point of the candle prior increasing its bullish tendancy. Default is false Returns: (series bool) True when pattern detected
tbLab(showLabel, labelColor, textColor) Produces "Tweezer Bottom" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
tweezerTop(closeLowerHalf) Detects "TweezerTop" candle patterns Parameters: closeLowerHalf: (bool) input to only detect setups that close below the mid-point of the candle prior increasing its bearish tendancy. Default is false Returns: (series bool) True when pattern detected
ttLab(showLabel, labelColor, textColor) Produces "TweezerTop" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
spinningTopBull(wickSize) Detects "Bullish Spinning Top" candle patterns Parameters: wickSize: (float) input to adjust detection of the size of the top wick/ bottom wick as a percent of total candle size. Default is 34%, which ensures the wicks are both larger than the body. Returns: (series bool) True when pattern detected
stwLab(showLabel, labelColor, textColor) Produces "Bullish Spinning Top" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
spinningTopBear(wickSize) Detects "Bearish Spinning Top" candle patterns Parameters: wickSize: (float) input to adjust detection of the size of the top wick/ bottom wick as a percent of total candle size. Default is 34%, which ensures the wicks are both larger than the body. Returns: (series bool) True when pattern detected
stbLab(showLabel, labelColor, textColor) Produces "Bearish Spinning Top" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
spinningTop(wickSize) Detects "Spinning Top" candle patterns Parameters: wickSize: (float) input to adjust detection of the size of the top wick/ bottom wick as a percent of total candle size. Default is 34%, which ensures the wicks are both larger than the body. Returns: (series bool) True when pattern detected
stLab(showLabel, labelColor, textColor) Produces "Spinning Top" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
msLab(showLabel, labelColor, textColor) Produces "Bullish Morning Star" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
esLab(showLabel, labelColor, textColor) Produces "Bearish Evening Star" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
hwLab(showLabel, labelColor, textColor) Produces "Bullish Harami" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
hbLab(showLabel, labelColor, textColor) Produces "Bearish Harami" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
hcwLab(showLabel, labelColor, textColor) Produces "Bullish Harami Cross" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
hcbLab(showLabel, labelColor) Produces "Bearish Harami Cross" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow Returns: (series label) A label visible at the chart level intended for the title pattern
mwLab(showLabel, labelColor, textColor) Produces "Bullish Marubozu" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
mbLab(showLabel, labelColor, textColor) Produces "Bearish Marubozu" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
abwLab(showLabel, labelColor, textColor) Produces "Bullish Abandoned Baby" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
abbLab(showLabel, labelColor, textColor) Produces "Bearish Abandoned Baby" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
pLab(showLabel, labelColor, textColor) Produces "Piercing" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
dccLab(showLabel, labelColor, textColor) Produces "Dark Cloud Cover" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
utgLab(showLabel, labelColor, textColor) Produces "Upside Tasuki Gap" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
dtgLab(showLabel, labelColor, textColor) Produces "Downside Tasuki Gap" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
risingThree() Detects "Rising Three Methods" candle patterns Returns: (series bool) True when pattern detected
rtmLab(showLabel, labelColor, textColor) Produces "Rising Three Methods" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
fallingThree() Detects "Falling Three Methods" candle patterns Returns: (series bool) True when pattern detected
ftmLab(showLabel, labelColor, textColor) Produces "Falling Three Methods" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
rwLab(showLabel, labelColor, textColor) Produces "Rising Window" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
fwLab(showLabel, labelColor, textColor) Produces "Falling Window" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
kwLab(showLabel, labelColor, textColor) Produces "Bullish Kicking" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
kbLab(showLabel, labelColor, textColor) Produces "Bearish Kicking" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
lls(ratio) Detects "Long Lower Shadow" candle patterns Parameters: ratio: (float) A relationship of the lower wick to the overall candle size expressed as a percent. Default is 75% Returns: (series bool) True when pattern detected
llsLab(showLabel, labelColor, textColor) Produces "Long Lower Shadow" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
lus(ratio) Detects "Long Upper Shadow" candle patterns Parameters: ratio: (float) A relationship of the upper wick to the overall candle size expressed as a percent. Default is 75% Returns: (series bool) True when pattern detected
lusLab(showLabel, labelColor, textColor) Produces "Long Upper Shadow" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
bullNeck() Detects "Bullish On Neck" candle patterns Returns: (series bool) True when pattern detected
nwLab(showLabel, labelColor, textColor) Produces "Bullish On Neck" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
bearNeck() Detects "Bearish On Neck" candle patterns Returns: (series bool) True when pattern detected
nbLab(showLabel, labelColor, textColor) Produces "Bearish On Neck" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
soldiers(wickSize) Detects "Three White Soldiers" candle patterns Parameters: wickSize: (float) Maximum allowable top wick size throughout pattern expressed as a percent of total candle height. Default is 5% Returns: (series bool) True when pattern detected
wsLab(showLabel, labelColor, textColor) Produces "Three White Soldiers" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
crows(wickSize) Detects "Three Black Crows" candle patterns Parameters: wickSize: (float) Maximum allowable bottom wick size throughout pattern expressed as a percent of total candle height. Default is 5% Returns: (series bool) True when pattern detected
bcLab(showLabel, labelColor, textColor) Produces "Three Black Crows" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
tswLab(showLabel, labelColor, textColor) Produces "Bullish Tri-Star" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
tsbLab(showLabel, labelColor, textColor) Produces "Bearish Tri-Star" identifier label Parameters: showLabel: (bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (series label) A label visible at the chart level intended for the title pattern
wrap(cond, barsBack, borderColor, bgcolor) Produces a box wrapping the highs and lows over the look back. Parameters: cond: (series bool) Condition under which to draw the box. barsBack: (series int) the number of bars back to begin drawing the box. borderColor: (series color) Color of the four borders. Optional. The default is color.gray. bgcolor: (series color) Background color of the box. Optional. The default is color.gray. Returns: (series box) A box who's top and bottom are above and below the highest and lowest points over the lookback
topWick() returns the top wick size of the current candle Returns: (series float) A value equivelent to the distance from the top of the candle body to its high
bottomWick() returns the bottom wick size of the current candle Returns: (series float) A value equivelent to the distance from the bottom of the candle body to its low
body() returns the body size of the current candle Returns: (series float) A value equivelent to the distance between the top and the bottom of the candle body
highestBody() returns the highest body of the current candle Returns: (series float) A value equivelent to the highest body, whether it is the open or the close
lowestBody() returns the lowest body of the current candle Returns: (series float) A value equivelent to the highest body, whether it is the open or the close
barRange() returns the height of the current candle Returns: (series float) A value equivelent to the distance between the high and the low of the candle
bodyPct() returns the body size as a percent Returns: (series float) A value equivelent to the percentage of body size to the overall candle size
midBody() returns the price of the mid-point of the candle body Returns: (series float) A value equivelent to the center point of the distance bewteen the body low and the body high
bodyupGap() returns true if there is a gap up between the real body of the current candle in relation to the candle prior Returns: (series bool) true if there is a gap up and no overlap in the real bodies of the current candle and the preceding candle
bodydwnGap() returns true if there is a gap down between the real body of the current candle in relation to the candle prior Returns: (series bool) true if there is a gap down and no overlap in the real bodies of the current candle and the preceding candle
gapUp() returns true if there is a gap down between the real body of the current candle in relation to the candle prior Returns: (series bool) true if there is a gap down and no overlap in the real bodies of the current candle and the preceding candle
gapDwn() returns true if there is a gap down between the real body of the current candle in relation to the candle prior Returns: (series bool) true if there is a gap down and no overlap in the real bodies of the current candle and the preceding candle
dojiBody() returns true if the candle body is a doji Returns: (series bool) true if the candle body is a doji. Defined by a body that is 5% of total candle size
ملاحظات الأخبار
⋅
v2
Minor updates for label tooltips
ملاحظات الأخبار
⋅
v3 updated wrap() default colors to combat small bug
ملاحظات الأخبار
⋅
v4
NEW FUNCTIONS "Inside" and "Double Inside" patterns with accompanying labels.
insLab(showLabel, labelColor, textColor) Produces "Inside Bar" identifier label Parameters: showLabel: (series bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (label) A label visible at the chart level intended for the title pattern
dinLab(showLabel, labelColor, textColor) Produces "Double Inside Bar" identifier label Parameters: showLabel: (series bool) Shows label when input is true. Default is false labelColor: (series color) Color of the label border and arrow textColor: (series color) Text color Returns: (label) A label visible at the chart level intended for the title pattern
@rob_in_banks, thank you for your support and generosity my friend !
joebaus
⋅
Absolutely phenomenal: cleanly written and presented!
Bjorgum
⋅
@joebaus, Thank you so much for the kind words my friend! Appreciate the support
PineCoders
⋅
Bjorgum
⋅
@PineCoders, Thank you kindly for your generosity !
UnknownUnicorn11728497
⋅
Thanks, great code
Project_Money_Heist
⋅
How to add it to indicators?
Bjorgum
⋅
@MaciekAthlone, this is a library for pinecoders to detect patterns in scripts of their own. If you want you can copy all the code and paste it in your pine editor and it will compile and show some patterns.
MMM424
⋅
Thank you for your work, why can't I copy and paste exactly?