// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © rhapsodyz
//@version=5
indicator(title = "Candlestick Patterns",
shorttitle = "Candle Patterns",
overlay = true)
// ##################
// === Parameters ===
// ##################
// === Trend Detecting Inputs ===
smaFastLength = input.int(50, minval = 1, maxval = 200, title = "SMA Fast Length", group = "Trend Detecting Settings")
smaSlowLength = input.int(200, minval = 1, maxval = 720, title = "SMA Slow Length", group = "Trend Detecting Settings")
// === Candlestick Inputs ===
perturbation = input.int(5, minval = 0, maxval = 20, title="Perturbation of Accuracy (%)", group = "Candlestick Settings")
C_Len = input.int(14, minval = 2, maxval = 360, title = "EMA depth of Body Average", group = "Candlestick Settings")
C_ShadowPercent = input.float(5.0, minval = 0.1, maxval = 20.0, title = "Size of Shadow (%)", group = "Candlestick Settings")
C_ShadowEqualsPercent = input.float(100.0, minval = 90.0, maxval = 110.0, title = "Equality of Shadow (%)", group = "Candlestick Settings")
C_DojiBodyPercent = input.float(5.0, minval = 0.1, maxval = 10.0, title = "Size of Doji (%)", group = "Candlestick Settings")
C_Factor = input.float(2.0, minval = 1.0, maxval = 3.0, title = "Factor of Shadow/Body", group = "Candlestick Settings")
pert = perturbation / 100
// === Candlestick Pattern Inputs"
// 弃婴。
AbandonedBabyInput = input(title = "弃婴", defval=false)
// 乌云盖顶。第一根阳线强劲实体,第二根阴线收盘于阳线中点以下。上涨动能正在被空头消耗。确认后形成阻力位。
DarkCloudCoverInput = input(title = "乌云盖顶", defval=true)
// 十字线。开盘价与收盘价几乎相等。市场分歧,犹豫不决。注意在趋势中位置。
DojiInput = input(title = "十字线" ,defval=true)
// 十字星。开盘价与收盘价几乎相等,且接近价格区间中点。市场分歧,犹豫不决。注意在趋势中位置。
DojiStarInput = input(title = "十字星" ,defval=true)
//
DownsideTasukiGapInput = input(title = "向下跳空并列" ,defval=false)
// 十字蜻蜓线。下影线较长,开盘/收盘价接近最高点。反转信号。
DragonflyDojiInput = input(title = "十字蜻蜓线" ,defval=true)
// 吞没。第二根实体包裹住第一根实体。处于明确趋势中,反转信号。确认后形成相应阻力位或支撑位。
EngulfingInput = input(title = "吞没" ,defval=true)
// 十字黄昏星。长-十字-长三根,第一和第三根位于中央十字星之下。位于上涨趋势表示看跌信号。确认后形成阻力位。
EveningDojiStarInput = input(title = "十字黄昏星" ,defval=true)
// 黄昏星。长-短-长三根,第一和第三根位于中央短实体之下。看跌信号。确认后形成阻力位。
EveningStarInput = input(title = "黄昏星" ,defval=true)
// 下跌三法。见于下跌趋势,连续出现三根较短阳线之后,行情将继续下跌。理想情况下,这三根阳线的长度不超过前一根阴线的烛身。上涨整理形态的标志是一根实体较长的阴线,预示市场将再度看跌。
FallingThreeMethodsInput = input(title = "下跌三法" ,defval=true)
FallingWindowInput = input(title = "下空窗口" ,defval=false)
// 十字墓碑线。几乎没有下影线。注意是否进一步构成十字黄昏星。多头失去动能。确认后形成阻力位。
GravestoneDojiInput = input(title = "十字墓碑线" ,defval=true)
// 锤子线。下影线很长,收盘价位于或接近高点。在大幅下跌或严重超卖区,注意可能反转。确认后形成支撑位。
HammerInput = input(title = "锤子线" ,defval=true)
// 上吊线。下影线很长,收盘价位于或接近高点。在上涨或严重超买区,注意可能反转。确认后形成阻力位。
HangingManInput = input(title = "上吊线" ,defval=true)
// 十字孕线。第一根长实体包裹住第二根小十字。反转概率大。
HaramiCrossInput = input(title = "十字孕线" ,defval=true)
// 孕线。第一根长实体包裹住第二根短实体。处于明确趋势中,反转信号,第一根线反转则信心更强,第二根越背离第一根中线则反转越强,否则可能横盘。
HaramiInput = input(title = "孕线" ,defval=true)
// 倒锤线。上影线特别长,实体特别小,与锤子线相反。处于下降趋势中为反转信号。确认后形成支撑位。
InvertedHammerInput = input(title = "倒锤线" ,defval=true)
// 反冲。
KickingInput = input(title = "反冲" ,defval=false)
// 长上影线。在高价区,阻力区或超买区可能是走熊征兆。
LongLowerShadowInput = input(title = "长下影线" ,defval=false)
// 长下影线。在支撑区或超卖区可能是走牛征兆。
LongUpperShadowInput = input(title = "长上影线" ,defval=false)
MarubozuBlackInput = input(title = "光头光脚阴线" ,defval=false)
MarubozuWhiteInput = input(title = "光头光脚阳线" ,defval=false)
// 十字启明星。长-十字-长三根,第一和第三根位于中央十字星之上。位于下跌趋势表示看涨信号。确认后形成支撑位。
MorningDojiStarInput = input(title = "十字启明星" ,defval=true)
// 启明星。长-短-长三根,第一和第三根位于中央短实体之上。位于下跌趋势表示看涨信号。确认后形成支撑位。
MorningStarInput = input(title = "启明星" ,defval=false)
// 待入线。
OnNeckInput = input(title = "待入线" ,defval=false)
// 刺穿。第一根阴线强劲实体,第二根阳线收盘于阴线中点以上。下跌动能遭遇多头奋力一搏。确认后形成支撑位。
PiercingInput = input(title = "刺穿" ,defval=true)
// 上涨三法。见于上涨趋势,连续出现三根较短阴线之后,行情将继续上涨。理想情况下,这三根阴线的长度不超过前一根阳线的烛身。上涨整理形态的标志是一根实体较长的阳线,预示市场将再度看涨。
RisingThreeMethodsInput = input(title = "上涨三法" ,defval=false)
// 上涨窗口。
RisingWindowInput = input(title = "上涨窗口" ,defval=false)
// 流星线。上影线很长,实体很小接近低点。在明确的上升走势之后,看空信号。确认后形成阻力位。
ShootingStarInput = input(title = "流星线" ,defval=true)
// 纺锤阴线。空头正在丧失动能,结合交易量判断是否“积聚”
SpinningTopBlackInput = input(title = "纺锤阴线" ,defval=false)
// 纺锤阳线。多头正在丧失动能,结合交易量判断是否“派发”
SpinningTopWhiteInput = input(title = "纺锤阳线" ,defval=false)
// 三只乌鸦。三根连续阴线,开盘价均在前一根实体范围内,而收盘价均低于前一根阴线的最低点。强劲卖压。
ThreeBlackCrowsInput = input(title = "三只乌鸦" ,defval=true)
// 前进三兵。三根连续阳线,开盘价均在前一根实体范围内,而收盘价均超过前一根阳线的最高点。强劲买压。
ThreeWhiteSoldiersInput = input(title = "前进三兵" ,defval=true)
TriStarInput = input(title = "三星形态" ,defval=false)
TweezerBottomInput = input(title = "镊子底" ,defval=true)
TweezerTopInput = input(title = "镊子顶" ,defval=true)
UpsideTasukiGapInput = input(title = "向上跳空并列" ,defval=false)
// ##################
// === Indicators ===
// ##################
// === Trend Detection ===
C_DownTrend = true
C_UpTrend = true
var trendRule1 = "SMA Single"
var trendRule2 = "SMA Double"
var trendRule = input.string(trendRule1, "Detect Trend Based On", options = [trendRule1, trendRule2, "No detection"])
if trendRule == trendRule1
priceAvg = ta.sma(close, smaFastLength)
C_DownTrend := close < priceAvg
C_UpTrend := close > priceAvg
if trendRule == trendRule2
smaSlow = ta.sma(close, smaSlowLength)
smaFast = ta.sma(close, smaFastLength)
C_DownTrend := close < smaFast and smaFast < smaSlow
C_UpTrend := close > smaFast and smaFast > smaSlow
// === Candlestick Properties ===
C_BodyHi = math.max(close, open) // spot 箱体高点
C_BodyLo = math.min(close, open) // spot 箱体低点
C_Body = C_BodyHi - C_BodyLo // length 箱体高度
C_BodyAvg = ta.ema(C_Body, C_Len) // length 箱体平均高度
C_SmallBody = C_Body < C_BodyAvg // boo 小箱体 多空力量相近
C_LongBody = C_Body > C_BodyAvg // boo 大箱体 多空力量差距较大
C_UpShadow = high - C_BodyHi // length 上影线长度
C_DnShadow = C_BodyLo - low // length 下影线长度
C_WhiteBody = open < close // boo 阳线
C_BlackBody = open > close // boo 阴线
C_Range = high-low // length 涨跌区间
C_BodyMiddle = C_Body / 2 + C_BodyLo // spot 箱体中线
C_HasUpShadow = C_UpShadow > C_ShadowPercent / 100 * C_Body // boo 有上影线
C_HasDnShadow = C_DnShadow > C_ShadowPercent / 100 * C_Body // boo 有下影线
C_IsInsideBar = C_BodyHi[1] > C_BodyHi and C_BodyLo[1] < C_BodyLo // boo 在前箱体内
C_ShadowEquals = C_UpShadow == C_DnShadow
or (math.abs(C_UpShadow - C_DnShadow) / C_DnShadow * 100) < C_ShadowEqualsPercent
and (math.abs(C_DnShadow - C_UpShadow) / C_UpShadow * 100) < C_ShadowEqualsPercent // boo 上下影线相等
C_IsDojiBody = C_Range > 0 and C_Body <= C_Range * C_DojiBodyPercent / 100 // boo 是十字线
C_Doji = C_IsDojiBody and C_ShadowEquals // boo 是十字星
patternLabelPosLow = low - (ta.atr(30) * 0.6)
patternLabelPosHigh = high + (ta.atr(30) * 0.6)
label_color_bullish = input(color.blue, "Label Color Bullish")
label_color_bearish = input(color.red, "Label Color Bearish")
label_color_neutral = input(color.gray, "Label Color Neutral")
CandleType = input.string(title = "Pattern Type", defval="Both", options=["Bullish", "Bearish", "Both"])
// #############
// === Plots ===
// #############
C_OnNeckBearishNumberOfCandles = 2
C_OnNeckBearish = false
if C_DownTrend and C_BlackBody[1] and C_LongBody[1] and C_WhiteBody and open < close[1] and C_SmallBody and C_Range!=0 and math.abs(close-low[1])<=C_BodyAvg*0.05
C_OnNeckBearish := true
alertcondition(C_OnNeckBearish, title = "On Neck – Bearish", message = "New On Neck – Bearish pattern detected")
if C_OnNeckBearish and OnNeckInput and (("Bearish" == CandleType) or CandleType == "Both")
var ttBearishOnNeck = "待入线 On Neck\nOn Neck is a two-line continuation pattern found in a downtrend. The first candle is long and red, the second candle is short and has a green body. The closing price of the second candle is close or equal to the first candle's low price. The pattern hints at a continuation of a downtrend, and penetrating the low of the green candlestick is sometimes considered a confirmation. "
label.new(bar_index, patternLabelPosHigh, text="ON", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishOnNeck)
C_RisingWindowBullishNumberOfCandles = 2
C_RisingWindowBullish = false
if C_UpTrend[1] and (C_Range!=0 and C_Range[1]!=0) and low > high[1]
C_RisingWindowBullish := true
alertcondition(C_RisingWindowBullish, title = "Rising Window – Bullish", message = "New Rising Window – Bullish pattern detected")
if C_RisingWindowBullish and RisingWindowInput and (("Bullish" == CandleType) or CandleType == "Both")
var ttBullishRisingWindow = "上涨窗口 Rising Window\nRising Window is a two-candle bullish continuation pattern that forms during an uptrend. Both candles in the pattern can be of any type with the exception of the Four-Price Doji. The most important characteristic of the pattern is a price gap between the first candle's high and the second candle's low. That gap (window) between two bars signifies support against the selling pressure."
label.new(bar_index, patternLabelPosLow, text="RW", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishRisingWindow)
C_FallingWindowBearishNumberOfCandles = 2
C_FallingWindowBearish = false
if C_DownTrend[1] and (C_Range!=0 and C_Range[1]!=0) and high < low[1]
C_FallingWindowBearish := true
alertcondition(C_FallingWindowBearish, title = "Falling Window – Bearish", message = "New Falling Window – Bearish pattern detected")
if C_FallingWindowBearish and FallingWindowInput and (("Bearish" == CandleType) or CandleType == "Both")
var ttBearishFallingWindow = "下跌窗口 Falling Window\nFalling Window is a two-candle bearish continuation pattern that forms during a downtrend. Both candles in the pattern can be of any type, with the exception of the Four-Price Doji. The most important characteristic of the pattern is a price gap between the first candle's low and the second candle's high. The existence of this gap (window) means that the bearish trend is expected to continue."
label.new(bar_index, patternLabelPosHigh, text="FW", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishFallingWindow)
C_FallingThreeMethodsBearishNumberOfCandles = 5
C_FallingThreeMethodsBearish = false
if C_DownTrend[4] and (C_LongBody[4] and C_BlackBody[4]) and (C_SmallBody[3] and C_WhiteBody[3] and open[3]>low[4] and close[3]<high[4]) and (C_SmallBody[2] and C_WhiteBody[2] and open[2]>low[4] and close[2]<high[4]) and (C_SmallBody[1] and C_WhiteBody[1] and open[1]>low[4] and close[1]<high[4]) and (C_LongBody and C_BlackBody and close<close[4])
C_FallingThreeMethodsBearish := true
alertcondition(C_FallingThreeMethodsBearish, title = "Falling Three Methods – Bearish", message = "New Falling Three Methods – Bearish pattern detected")
if C_FallingThreeMethodsBearish and FallingThreeMethodsInput and (("Bearish" == CandleType) or CandleType == "Both")
var ttBearishFallingThreeMethods = "下跌三法 Falling Three Methods\n见于下跌趋势,连续出现三根较短阳线之后,行情将继续下跌。理想情况下,这三根阳线的长度不超过前一根阴线的烛身。上涨整理形态的标志是一根实体较长的阴线,预示市场将再度看跌。"
label.new(bar_index, patternLabelPosHigh, text="FTM", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishFallingThreeMethods)
C_RisingThreeMethodsBullishNumberOfCandles = 5
C_RisingThreeMethodsBullish = false
if C_UpTrend[4] and (C_LongBody[4] and C_WhiteBody[4]) and (C_SmallBody[3] and C_BlackBody[3] and open[3]<high[4] and close[3]>low[4]) and (C_SmallBody[2] and C_BlackBody[2] and open[2]<high[4] and close[2]>low[4]) and (C_SmallBody[1] and C_BlackBody[1] and open[1]<high[4] and close[1]>low[4]) and (C_LongBody and C_WhiteBody and close>close[4])
C_RisingThreeMethodsBullish := true
alertcondition(C_RisingThreeMethodsBullish, title = "Rising Three Methods – Bullish", message = "New Rising Three Methods – Bullish pattern detected")
if C_RisingThreeMethodsBullish and RisingThreeMethodsInput and (("Bullish" == CandleType) or CandleType == "Both")
var ttBullishRisingThreeMethods = "上涨三法 Rising Three Methods\n见于上涨趋势,连续出现三根较短阴线之后,行情将继续上涨。理想情况下,这三根阴线的长度不超过前一根阳线的烛身。上涨整理形态的标志是一根实体较长的阳线,预示市场将再度看涨。"
label.new(bar_index, patternLabelPosLow, text="RTM", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishRisingThreeMethods)
C_TweezerTopBearishNumberOfCandles = 2
C_TweezerTopBearish = false
if C_UpTrend[1] and (not C_IsDojiBody or (C_HasUpShadow and C_HasDnShadow)) and math.abs(high-high[1]) <= C_BodyAvg*0.05 and C_WhiteBody[1] and C_BlackBody and C_LongBody[1]
C_TweezerTopBearish := true
alertcondition(C_TweezerTopBearish, title = "Tweezer Top – Bearish", message = "New Tweezer Top – Bearish pattern detected")
if C_TweezerTopBearish and TweezerTopInput and (("Bearish" == CandleType) or CandleType == "Both")
var ttBearishTweezerTop = "镊子顶 Tweezer Top\nTweezer Top is a two-candle pattern that signifies a potential bearish reversal. The pattern is found during an uptrend. The first candle is long and green, the second candle is red, and its high is nearly identical to the high of the previous candle. The virtually identical highs, together with the inverted directions, hint that bears might be taking over the market."
label.new(bar_index, patternLabelPosHigh, text="TT", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishTweezerTop)
C_TweezerBottomBullishNumberOfCandles = 2
C_TweezerBottomBullish = false
if C_DownTrend[1] and (not C_IsDojiBody or (C_HasUpShadow and C_HasDnShadow)) and math.abs(low-low[1]) <= C_BodyAvg*0.05 and C_BlackBody[1] and C_WhiteBody and C_LongBody[1]
C_TweezerBottomBullish := true
alertcondition(C_TweezerBottomBullish, title = "Tweezer Bottom – Bullish", message = "New Tweezer Bottom – Bullish pattern detected")
if C_TweezerBottomBullish and TweezerBottomInput and (("Bullish" == CandleType) or CandleType == "Both")
var ttBullishTweezerBottom = "镊子底 Tweezer Bottom\nTweezer Bottom is a two-candle pattern that signifies a potential bullish reversal. The pattern is found during a downtrend. The first candle is long and red, the second candle is green, its lows nearly identical to the low of the previous candle. The virtually identical lows together with the inverted directions hint that bulls might be taking over the market."
label.new(bar_index, patternLabelPosLow, text="TB", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishTweezerBottom)
C_DarkCloudCoverBearishNumberOfCandles = 2
C_DarkCloudCoverBearish = false
if (C_UpTrend[1] and C_WhiteBody[1] and C_LongBody[1]) and (C_BlackBody and close < C_BodyMiddle[1] and close > open[1])
C_DarkCloudCoverBearish := true
alertcondition(C_DarkCloudCoverBearish, title = "Dark Cloud Cover – Bearish", message = "New Dark Cloud Cover – Bearish pattern detected")
if C_DarkCloudCoverBearish and DarkCloudCoverInput and (("Bearish" == CandleType) or CandleType == "Both")
var ttBearishDarkCloudCover = "乌云盖顶 Dark Cloud Cover\n 第一根阳线强劲实体,第二根阴线收盘于阳线中点以下。上涨动能正在被空头消耗。确认后形成阻力位。"
label.new(bar_index, patternLabelPosHigh, text="DCC", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishDarkCloudCover)
C_DownsideTasukiGapBearishNumberOfCandles = 3
C_DownsideTasukiGapBearish = false
if C_LongBody[2] and C_SmallBody[1] and C_DownTrend and C_BlackBody[2] and C_BodyHi[1] <= (C_BodyLo[2] + pert * C_BodyAvg) and C_BlackBody[1] and C_WhiteBody and C_BodyHi <= (C_BodyLo[2] + pert * C_BodyAvg) and C_BodyHi >= (C_BodyHi[1] - pert * C_BodyAvg)
C_DownsideTasukiGapBearish := true
alertcondition(C_DownsideTasukiGapBearish, title = "Downside Tasuki Gap – Bearish", message = "New Downside Tasuki Gap – Bearish pattern detected")
if C_DownsideTasukiGapBearish and DownsideTasukiGapInput and (("Bearish" == CandleType) or CandleType == "Both")
var ttBearishDownsideTasukiGap = "向下跳空并列 Downside Tasuki Gap\nDownside Tasuki Gap is a three-candle pattern found in a downtrend that usually hints at the continuation of the downtrend. The first candle is long and red, followed by a smaller red candle with its opening price that gaps below the body of the previous candle. The third candle is green and it closes inside the gap created by the first two candles, unable to close it fully. The bull’s inability to close that gap hints that the downtrend might continue."
label.new(bar_index, patternLabelPosHigh, text="DTG", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishDownsideTasukiGap)
C_UpsideTasukiGapBullishNumberOfCandles = 3
C_UpsideTasukiGapBullish = false
if C_LongBody[2] and C_SmallBody[1] and C_UpTrend and C_WhiteBody[2] and C_BodyLo[1] >= (C_BodyHi[2] - pert * C_BodyAvg) and C_WhiteBody[1] and C_BlackBody and C_BodyLo >= C_BodyHi[2] and C_BodyLo <= (C_BodyLo[1] + pert * C_BodyAvg)
C_UpsideTasukiGapBullish := true
alertcondition(C_UpsideTasukiGapBullish, title = "Upside Tasuki Gap – Bullish", message = "New Upside Tasuki Gap – Bullish pattern detected")
if C_UpsideTasukiGapBullish and UpsideTasukiGapInput and (("Bullish" == CandleType) or CandleType == "Both")
var ttBullishUpsideTasukiGap = "向上跳空并列 Upside Tasuki Gap\nUpside Tasuki Gap is a three-candle pattern found in an uptrend that usually hints at the continuation of the uptrend. The first candle is long and green, followed by a smaller green candle with its opening price that gaps above the body of the previous candle. The third candle is red and it closes inside the gap created by the first two candles, unable to close it fully. The bear’s inability to close the gap hints that the uptrend might continue."
label.new(bar_index, patternLabelPosLow, text="UTG", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishUpsideTasukiGap)
C_EveningDojiStarBearishNumberOfCandles = 3
C_EveningDojiStarBearish = false
if C_LongBody[2] and C_IsDojiBody[1] and C_LongBody and C_UpTrend and C_WhiteBody[2] and C_BodyLo[1] >= (C_BodyHi[2] - pert * C_BodyAvg) and C_BlackBody and C_BodyLo <= C_BodyMiddle[2] and C_BodyLo > C_BodyLo[2] and C_BodyLo[1] >= (C_BodyHi - pert * C_BodyAvg)
C_EveningDojiStarBearish := true
alertcondition(C_EveningDojiStarBearish, title = "Evening Doji Star – Bearish", message = "New Evening Doji Star – Bearish pattern detected")
if C_EveningDojiStarBearish and EveningDojiStarInput and (("Bearish" == CandleType) or CandleType == "Both")
var ttBearishEveningDojiStar = "十字黄昏星 Evening Doji Star\n长-十字-长三根,第一和第三根位于中央十字星之下。看跌信号。确认后形成阻力位。"
label.new(bar_index, patternLabelPosHigh, text="EDS", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishEveningDojiStar)
C_DojiStarBearishNumberOfCandles = 2
C_DojiStarBearish = false
if C_UpTrend and C_WhiteBody[1] and C_LongBody[1] and C_IsDojiBody and C_BodyLo >= (C_BodyHi[1] - pert * C_BodyAvg)
C_DojiStarBearish := true
alertcondition(C_DojiStarBearish, title = "Doji Star – Bearish", message = "New Doji Star – Bearish pattern detected")
if C_DojiStarBearish and DojiStarInput and (("Bearish" == CandleType) or CandleType == "Both")
var ttBearishDojiStar = "看跌十字星 Doji Star\n开盘价与收盘价几乎相等,且接近价格区间中点。市场分歧,犹豫不决。"
label.new(bar_index, patternLabelPosHigh, text="DS", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishDojiStar)
C_DojiStarBullishNumberOfCandles = 2
C_DojiStarBullish = false
if C_DownTrend and C_BlackBody[1] and C_LongBody[1] and C_IsDojiBody and C_BodyHi <= (C_BodyLo[1] + pert * C_BodyAvg)
C_DojiStarBullish := true
alertcondition(C_DojiStarBullish, title = "Doji Star – Bullish", message = "New Doji Star – Bullish pattern detected")
if C_DojiStarBullish and DojiStarInput and (("Bullish" == CandleType) or CandleType == "Both")
var ttBullishDojiStar = "看涨十字星 Doji Star\n开盘价与收盘价几乎相等,且接近价格区间中点。市场分歧,犹豫不决。"
label.new(bar_index, patternLabelPosLow, text="DS", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishDojiStar)
C_MorningDojiStarBullishNumberOfCandles = 3
C_MorningDojiStarBullish = false
if C_LongBody[2] and C_IsDojiBody[1] and C_LongBody and C_DownTrend and C_BlackBody[2] and C_BodyHi[1] <= (C_BodyLo[2] + pert * C_BodyAvg) and C_WhiteBody and C_BodyHi >= C_BodyMiddle[2] and C_BodyHi <= C_BodyHi[2] and C_BodyHi[1] <= (C_BodyLo + pert * C_BodyAvg)
C_MorningDojiStarBullish := true
alertcondition(C_MorningDojiStarBullish, title = "Morning Doji Star – Bullish", message = "New Morning Doji Star – Bullish pattern detected")
if C_MorningDojiStarBullish and MorningDojiStarInput and (("Bullish" == CandleType) or CandleType == "Both")
var ttBullishMorningDojiStar = "十字启明星 Morning Doji Star\n长-十字-长三根,第一和第三根位于中央十字星之上。位于下跌趋势表示看涨信号。确认后形成支撑位。"
label.new(bar_index, patternLabelPosLow, text="MDS", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishMorningDojiStar)
C_PiercingBullishNumberOfCandles = 2
C_PiercingBullish = false
if (C_DownTrend[1] and C_BlackBody[1] and C_LongBody[1]) and (C_WhiteBody and open <= (low[1] + pert * C_BodyAvg) and close > C_BodyMiddle[1] and close < open[1])
C_PiercingBullish := true
alertcondition(C_PiercingBullish, title = "Piercing – Bullish", message = "New Piercing – Bullish pattern detected")
if C_PiercingBullish and PiercingInput and (("Bullish" == CandleType) or CandleType == "Both")
var ttBullishPiercing = "刺穿 Piercing\n第一根阴线强劲实体,第二根阳线收盘于阴线中点以上。下跌动能遭遇多头奋力一搏。确认后形成支撑位。"
label.new(bar_index, patternLabelPosLow, text="P", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishPiercing)
C_HammerBullishNumberOfCandles = 1
C_HammerBullish = false
if C_SmallBody and C_Body > 0 and C_BodyLo > hl2 and C_DnShadow >= C_Factor * C_Body and not C_HasUpShadow
if C_DownTrend
C_HammerBullish := true
alertcondition(C_HammerBullish, title = "Hammer – Bullish", message = "New Hammer – Bullish pattern detected")
if C_HammerBullish and HammerInput and (("Bullish" == CandleType) or CandleType == "Both")
var ttBullishHammer = "锤子线 Hammer\n下影线很长,收盘价位于或接近高点。在大幅下跌或严重超卖区,注意可能反转。确认后形成支撑位。"
label.new(bar_index, patternLabelPosLow, text="H", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishHammer)
C_HangingManBearishNumberOfCandles = 1
C_HangingManBearish = false
if C_SmallBody and C_Body > 0 and C_BodyLo > hl2 and C_DnShadow >= C_Factor * C_Body and not C_HasUpShadow
if C_UpTrend
C_HangingManBearish := true
alertcondition(C_HangingManBearish, title = "Hanging Man – Bearish", message = "New Hanging Man – Bearish pattern detected")
if C_HangingManBearish and HangingManInput and (("Bearish" == CandleType) or CandleType == "Both")
var ttBearishHangingMan = "上吊线 Hanging Man\n下影线很长,收盘价位于或接近高点。在上涨或严重超买区,注意可能反转。确认后形成阻力位。"
label.new(bar_index, patternLabelPosHigh, text="HM", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishHangingMan)
C_ShootingStarBearishNumberOfCandles = 1
C_ShootingStarBearish = false
if C_SmallBody and C_Body > 0 and C_BodyHi < hl2 and C_UpShadow >= C_Factor * C_Body and not C_HasDnShadow
if C_UpTrend
C_ShootingStarBearish := true
alertcondition(C_ShootingStarBearish, title = "Shooting Star – Bearish", message = "New Shooting Star – Bearish pattern detected")
if C_ShootingStarBearish and ShootingStarInput and (("Bearish" == CandleType) or CandleType == "Both")
var ttBearishShootingStar = "流星线 Shooting Star\n上影线很长,实体很小接近低点。在明确的上升走势之后,看空信号。确认后形成阻力位。"
label.new(bar_index, patternLabelPosHigh, text="SS", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishShootingStar)
C_InvertedHammerBullishNumberOfCandles = 1
C_InvertedHammerBullish = false
if C_SmallBody and C_Body > 0 and C_BodyHi < hl2 and C_UpShadow >= C_Factor * C_Body and not C_HasDnShadow
if C_DownTrend
C_InvertedHammerBullish := true
alertcondition(C_InvertedHammerBullish, title = "Inverted Hammer – Bullish", message = "New Inverted Hammer – Bullish pattern detected")
if C_InvertedHammerBullish and InvertedHammerInput and (("Bullish" == CandleType) or CandleType == "Both")
var ttBullishInvertedHammer = "倒锤线 Inverted Hammer\n上影线特别长,实体特别小,与锤子线相反。处于下降趋势中为反转信号。确认后形成支撑位。"
label.new(bar_index, patternLabelPosLow, text="IH", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishInvertedHammer)
C_MorningStarBullishNumberOfCandles = 3
C_MorningStarBullish = false
if C_LongBody[2] and C_SmallBody[1] and C_LongBody
if C_DownTrend and C_BlackBody[2] and C_BodyHi[1] <= (C_BodyLo[2] + pert * C_BodyAvg) and C_WhiteBody and C_BodyHi >= C_BodyMiddle[2] and C_BodyHi < C_BodyHi[2] and C_BodyHi[1] <= (C_BodyLo + pert * C_BodyAvg)
C_MorningStarBullish := true
alertcondition(C_MorningStarBullish, title = "Morning Star – Bullish", message = "New Morning Star – Bullish pattern detected")
if C_MorningStarBullish and MorningStarInput and (("Bullish" == CandleType) or CandleType == "Both")
var ttBullishMorningStar = "启明星 Morning Star\n长-短-长三根,第一和第三根位于中央短实体之上。位于下跌趋势表示看涨信号。确认后形成支撑位。"
label.new(bar_index, patternLabelPosLow, text="MS", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishMorningStar)
C_EveningStarBearishNumberOfCandles = 3
C_EveningStarBearish = false
if C_LongBody[2] and C_SmallBody[1] and C_LongBody
if C_UpTrend and C_WhiteBody[2] and C_BodyLo[1] >= (C_BodyHi[2] - pert * C_BodyAvg) and C_BlackBody and C_BodyLo <= C_BodyMiddle[2] and C_BodyLo > C_BodyLo[2] and C_BodyLo[1] >= (C_BodyHi - pert * C_BodyAvg)
C_EveningStarBearish := true
alertcondition(C_EveningStarBearish, title = "Evening Star – Bearish", message = "New Evening Star – Bearish pattern detected")
if C_EveningStarBearish and EveningStarInput and (("Bearish" == CandleType) or CandleType == "Both")
var ttBearishEveningStar = "黄昏星 Evening Star\n长-短-长三根,第一和第三根位于中央短实体之下。看跌信号。确认后形成阻力位。"
label.new(bar_index, patternLabelPosHigh, text="ES", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishEveningStar)
C_MarubozuWhiteBullishNumberOfCandles = 1
C_MarubozuShadowPercentWhite = 5.0
C_MarubozuWhiteBullish = C_WhiteBody and C_LongBody and C_UpShadow <= C_MarubozuShadowPercentWhite/100*C_Body and C_DnShadow <= C_MarubozuShadowPercentWhite/100*C_Body and C_WhiteBody
alertcondition(C_MarubozuWhiteBullish, title = "Marubozu White – Bullish", message = "New Marubozu White – Bullish pattern detected")
if C_MarubozuWhiteBullish and MarubozuWhiteInput and (("Bullish" == CandleType) or CandleType == "Both")
var ttBullishMarubozuWhite = "光头光脚阳线 Marubozu White\nA Marubozu White Candle is a candlestick that does not have a shadow that extends from its candle body at either the open or the close. Marubozu is Japanese for “close-cropped” or “close-cut.” Other sources may call it a Bald or Shaven Head Candle."
label.new(bar_index, patternLabelPosLow, text="MW", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishMarubozuWhite)
C_MarubozuBlackBearishNumberOfCandles = 1
C_MarubozuShadowPercentBearish = 5.0
C_MarubozuBlackBearish = C_BlackBody and C_LongBody and C_UpShadow <= C_MarubozuShadowPercentBearish/100*C_Body and C_DnShadow <= C_MarubozuShadowPercentBearish/100*C_Body and C_BlackBody
alertcondition(C_MarubozuBlackBearish, title = "Marubozu Black – Bearish", message = "New Marubozu Black – Bearish pattern detected")
if C_MarubozuBlackBearish and MarubozuBlackInput and (("Bearish" == CandleType) or CandleType == "Both")
var ttBearishMarubozuBlack = "光头光脚阴线 Marubozu Black\nThis is a candlestick that has no shadow, which extends from the red-bodied candle at the open, the close, or even at both. In Japanese, the name means “close-cropped” or “close-cut.” The candlestick can also be referred to as Bald or Shaven Head."
label.new(bar_index, patternLabelPosHigh, text="MB", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishMarubozuBlack)
C_DojiNumberOfCandles = 1
C_DragonflyDoji = C_IsDojiBody and C_UpShadow <= C_Body
C_GravestoneDojiOne = C_IsDojiBody and C_DnShadow <= C_Body
alertcondition(C_Doji and not C_DragonflyDoji and not C_GravestoneDojiOne, title = "Doji", message = "New Doji pattern detected")
if C_Doji and not C_DragonflyDoji and not C_GravestoneDojiOne and DojiInput
var ttDoji = "十字线 Doji\n开盘价与收盘价几乎相等。市场分歧,犹豫不决。注意在趋势中位置。"
label.new(bar_index, patternLabelPosLow, text="D", style=label.style_label_up, color = label_color_neutral, textcolor=color.white, tooltip = ttDoji)
C_GravestoneDojiBearishNumberOfCandles = 1
C_GravestoneDojiBearish = C_IsDojiBody and C_DnShadow <= C_Body
alertcondition(C_GravestoneDojiBearish, title = "Gravestone Doji – Bearish", message = "New Gravestone Doji – Bearish pattern detected")
if C_GravestoneDojiBearish and GravestoneDojiInput and (("Bearish" == CandleType) or CandleType == "Both")
var ttBearishGravestoneDoji = "墓碑十字线 Gravestone Doji\n几乎没有下影线。注意是否进一步构成十字黄昏星。多头失去动能。确认后形成阻力位。"
label.new(bar_index, patternLabelPosHigh, text="GD", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishGravestoneDoji)
C_DragonflyDojiBullishNumberOfCandles = 1
C_DragonflyDojiBullish = C_IsDojiBody and C_UpShadow <= C_Body
alertcondition(C_DragonflyDojiBullish, title = "Dragonfly Doji – Bullish", message = "New Dragonfly Doji – Bullish pattern detected")
if C_DragonflyDojiBullish and DragonflyDojiInput and (("Bullish" == CandleType) or CandleType == "Both")
var ttBullishDragonflyDoji = "蜻蜓十字线 Dragonfly Doji\n下影线较长,开盘/收盘价接近最高点。反转信号。"
label.new(bar_index, patternLabelPosLow, text="DD", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishDragonflyDoji)
C_HaramiCrossBullishNumberOfCandles = 2
C_HaramiCrossBullish = C_LongBody[1] and C_BlackBody[1] and C_DownTrend[1] and C_IsDojiBody and high <= C_BodyHi[1] and low >= C_BodyLo[1]
alertcondition(C_HaramiCrossBullish, title = "Harami Cross – Bullish", message = "New Harami Cross – Bullish pattern detected")
if C_HaramiCrossBullish and HaramiCrossInput and (("Bullish" == CandleType) or CandleType == "Both")
var ttBullishHaramiCross = "十字看涨孕线 Harami Cross\n第一根长实体包裹住第二根十字。处于明确趋势中,反转信号,第一根是阳线反转则信心更强,第二根越背离第一根中线往顶部走则上涨信号越强,否则可能横盘。"
label.new(bar_index, patternLabelPosLow, text="HC", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishHaramiCross)
C_HaramiCrossBearishNumberOfCandles = 2
C_HaramiCrossBearish = C_LongBody[1] and C_WhiteBody[1] and C_UpTrend[1] and C_IsDojiBody and high <= C_BodyHi[1] and low >= C_BodyLo[1]
alertcondition(C_HaramiCrossBearish, title = "Harami Cross – Bearish", message = "New Harami Cross – Bearish pattern detected")
if C_HaramiCrossBearish and HaramiCrossInput and (("Bearish" == CandleType) or CandleType == "Both")
var ttBearishHaramiCross = "十字看跌孕线 Harami Cross\n第一根长实体包裹住第二根十字。处于明确趋势中,反转信号,第一根是阴线反转则信心更强,第二根越背离第一根中线往底部走则下跌信号越强,否则可能横盘。"
label.new(bar_index, patternLabelPosHigh, text="HC", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishHaramiCross)
C_HaramiBullishNumberOfCandles = 2
C_HaramiBullish = C_LongBody[1] and C_BlackBody[1] and C_DownTrend[1] and C_WhiteBody and C_SmallBody and high <= C_BodyHi[1] and low >= C_BodyLo[1]
alertcondition(C_HaramiBullish, title = "Harami – Bullish", message = "New Harami – Bullish pattern detected")
if C_HaramiBullish and HaramiInput and (("Bullish" == CandleType) or CandleType == "Both")
var ttBullishHarami = "看涨孕线 Harami\n第一根长实体包裹住第二根短实体。处于明确趋势中,反转信号,第一根线反转则信心更强,第二根越背离第一根中线则反转越强,否则可能横盘。"
label.new(bar_index, patternLabelPosLow, text="BH", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishHarami)
C_HaramiBearishNumberOfCandles = 2
C_HaramiBearish = C_LongBody[1] and C_WhiteBody[1] and C_UpTrend[1] and C_BlackBody and C_SmallBody and high <= C_BodyHi[1] and low >= C_BodyLo[1]
alertcondition(C_HaramiBearish, title = "Harami – Bearish", message = "New Harami – Bearish pattern detected")
if C_HaramiBearish and HaramiInput and (("Bearish" == CandleType) or CandleType == "Both")
var ttBearishHarami = "看跌孕线 Harami\n第一根长实体包裹住第二根短实体。处于明确趋势中,反转信号,第一根线反转则信心更强,第二根越背离第一根中线则反转越强,否则可能横盘。"
label.new(bar_index, patternLabelPosHigh, text="BH", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishHarami)
C_LongLowerShadowBullishNumberOfCandles = 1
C_LongLowerShadowPercent = 75.0
C_LongLowerShadowBullish = C_DnShadow > C_Range/100*C_LongLowerShadowPercent
alertcondition(C_LongLowerShadowBullish, title = "Long Lower Shadow – Bullish", message = "New Long Lower Shadow – Bullish pattern detected")
if C_LongLowerShadowBullish and LongLowerShadowInput and (("Bullish" == CandleType) or CandleType == "Both")
var ttBullishLongLowerShadow = "长下影线 Long Lower Shadow\nTo indicate seller domination of the first part of a session, candlesticks will present with long lower shadows and short upper shadows, consequently lowering prices."
label.new(bar_index, patternLabelPosLow, text="LLS", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishLongLowerShadow)
C_LongUpperShadowBearishNumberOfCandles = 1
C_LongShadowPercent = 75.0
C_LongUpperShadowBearish = C_UpShadow > C_Range/100*C_LongShadowPercent
alertcondition(C_LongUpperShadowBearish, title = "Long Upper Shadow – Bearish", message = "New Long Upper Shadow – Bearish pattern detected")
if C_LongUpperShadowBearish and LongUpperShadowInput and (("Bearish" == CandleType) or CandleType == "Both")
var ttBearishLongUpperShadow = "长上影线 Long Upper Shadow\nTo indicate buyer domination of the first part of a session, candlesticks will present with long upper shadows, as well as short lower shadows, consequently raising bidding prices."
label.new(bar_index, patternLabelPosHigh, text="LUS", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishLongUpperShadow)
C_SpinningTopWhiteNumberOfCandles = 1
C_SpinningTopWhitePercent = 34.0
C_IsSpinningTopWhite = C_DnShadow >= C_Range / 100 * C_SpinningTopWhitePercent and C_UpShadow >= C_Range / 100 * C_SpinningTopWhitePercent and not C_IsDojiBody
C_SpinningTopWhite = C_IsSpinningTopWhite and C_WhiteBody
alertcondition(C_SpinningTopWhite, title = "Spinning Top White", message = "New Spinning Top White pattern detected")
if C_SpinningTopWhite and SpinningTopWhiteInput
var ttSpinningTopWhite = "纺锤阳线 Spinning Top White\nWhite spinning tops are candlestick lines that are small, green-bodied, and possess shadows (upper and lower) that end up exceeding the length of candle bodies. They often signal indecision between buyer and seller."
label.new(bar_index, patternLabelPosLow, text="STW", style=label.style_label_up, color = label_color_neutral, textcolor=color.white, tooltip = ttSpinningTopWhite)
C_SpinningTopBlackNumberOfCandles = 1
C_SpinningTopBlackPercent = 34.0
C_IsSpinningTop = C_DnShadow >= C_Range / 100 * C_SpinningTopBlackPercent and C_UpShadow >= C_Range / 100 * C_SpinningTopBlackPercent and not C_IsDojiBody
C_SpinningTopBlack = C_IsSpinningTop and C_BlackBody
alertcondition(C_SpinningTopBlack, title = "Spinning Top Black", message = "New Spinning Top Black pattern detected")
if C_SpinningTopBlack and SpinningTopBlackInput
var ttSpinningTopBlack = "纺锤阴线 Spinning Top Black\nBlack spinning tops are candlestick lines that are small, red-bodied, and possess shadows (upper and lower) that end up exceeding the length of candle bodies. They often signal indecision."
label.new(bar_index, patternLabelPosLow, text="STB", style=label.style_label_up, color = label_color_neutral, textcolor=color.white, tooltip = ttSpinningTopBlack)
C_ThreeWhiteSoldiersBullishNumberOfCandles = 3
C_3WSld_ShadowPercent = 5.0
C_3WSld_HaveNotUpShadow = C_Range * C_3WSld_ShadowPercent / 100 > C_UpShadow
C_ThreeWhiteSoldiersBullish = false
if C_LongBody and C_LongBody[1] and C_LongBody[2]
if C_WhiteBody and C_WhiteBody[1] and C_WhiteBody[2]
C_ThreeWhiteSoldiersBullish := close > close[1] and close[1] > close[2] and open > open[1] and open[1] > open[2] and C_3WSld_HaveNotUpShadow and C_3WSld_HaveNotUpShadow[1] and C_3WSld_HaveNotUpShadow[2]
alertcondition(C_ThreeWhiteSoldiersBullish, title = "Three White Soldiers – Bullish", message = "New Three White Soldiers – Bullish pattern detected")
if C_ThreeWhiteSoldiersBullish and ThreeWhiteSoldiersInput and (("Bullish" == CandleType) or CandleType == "Both")
var ttBullishThreeWhiteSoldiers = "前进三兵 Three White Soldiers\n三根连续阳线,开盘价均在前一根烛线的烛身范围内,而收盘价均超过前一根烛线的最高点。强劲买压。"
label.new(bar_index, patternLabelPosLow, text="3WS", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishThreeWhiteSoldiers)
C_ThreeBlackCrowsBearishNumberOfCandles = 3
C_3BCrw_ShadowPercent = 5.0
C_3BCrw_HaveNotDnShadow = C_Range * C_3BCrw_ShadowPercent / 100 > C_DnShadow
C_ThreeBlackCrowsBearish = false
if C_LongBody and C_LongBody[1] and C_LongBody[2]
if C_BlackBody and C_BlackBody[1] and C_BlackBody[2]
C_ThreeBlackCrowsBearish := close < close[1] and close[1] < close[2] and open < open[1] and open[1] < open[2] and C_3BCrw_HaveNotDnShadow and C_3BCrw_HaveNotDnShadow[1] and C_3BCrw_HaveNotDnShadow[2]
alertcondition(C_ThreeBlackCrowsBearish, title = "Three Black Crows – Bearish", message = "New Three Black Crows – Bearish pattern detected")
if C_ThreeBlackCrowsBearish and ThreeBlackCrowsInput and (("Bearish" == CandleType) or CandleType == "Both")
var ttBearishThreeBlackCrows = "三只乌鸦 Three Black Crows\n三根连续阴线,开盘价均在前一根实体范围内,而收盘价均低于前一根阴线的最低点。强劲卖压。"
label.new(bar_index, patternLabelPosHigh, text="3BC", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishThreeBlackCrows)
C_EngulfingBullishNumberOfCandles = 2
C_EngulfingBullish = C_DownTrend and C_WhiteBody and C_LongBody and C_BlackBody[1] and close >= open[1]
alertcondition(C_EngulfingBullish, title = "Engulfing – Bullish", message = "New Engulfing – Bullish pattern detected")
if C_EngulfingBullish and EngulfingInput and (("Bullish" == CandleType) or CandleType == "Both")
var ttBullishEngulfing = "多头吞没 Engulfing\n第二根阳线包裹住第一根阴线。处于明确下跌趋势中,反转信号。确认后形成支撑位。"
label.new(bar_index, patternLabelPosLow, text="BE", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishEngulfing)
C_EngulfingBearishNumberOfCandles = 2
C_EngulfingBearish = C_UpTrend and C_BlackBody and C_LongBody and C_WhiteBody[1] and close <= open[1]
alertcondition(C_EngulfingBearish, title = "Engulfing – Bearish", message = "New Engulfing – Bearish pattern detected")
if C_EngulfingBearish and EngulfingInput and (("Bearish" == CandleType) or CandleType == "Both")
var ttBearishEngulfing = "空头吞没 Engulfing\n第二根阴线包裹住第一根阳线。处于明确上升趋势中,反转信号。确认后形成阻力位。"
label.new(bar_index, patternLabelPosHigh, text="BE", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishEngulfing)
C_AbandonedBabyBullishNumberOfCandles = 3
C_AbandonedBabyBullish = C_DownTrend[2] and C_BlackBody[2] and C_IsDojiBody[1] and low[2] > high[1] and C_WhiteBody and high[1] < low
alertcondition(C_AbandonedBabyBullish, title = "Abandoned Baby – Bullish", message = "New Abandoned Baby – Bullish pattern detected")
if C_AbandonedBabyBullish and AbandonedBabyInput and (("Bullish" == CandleType) or CandleType == "Both")
var ttBullishAbandonedBaby = "看涨弃婴 Abandoned Baby\nThis candlestick pattern is quite rare as far as reversal patterns go. The first of the pattern is a large down candle. Next comes a doji candle that gaps below the candle before it. The doji candle is then followed by another candle that opens even higher and swiftly moves to the upside."
label.new(bar_index, patternLabelPosLow, text="AB", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishAbandonedBaby)
C_AbandonedBabyBearishNumberOfCandles = 3
C_AbandonedBabyBearish = C_UpTrend[2] and C_WhiteBody[2] and C_IsDojiBody[1] and high[2] < low[1] and C_BlackBody and low[1] > high
alertcondition(C_AbandonedBabyBearish, title = "Abandoned Baby – Bearish", message = "New Abandoned Baby – Bearish pattern detected")
if C_AbandonedBabyBearish and AbandonedBabyInput and (("Bearish" == CandleType) or CandleType == "Both")
var ttBearishAbandonedBaby = "看跌弃婴 Abandoned Baby\nA bearish abandoned baby is a specific candlestick pattern that often signals a downward reversal trend in terms of security price. It is formed when a gap appears between the lowest price of a doji-like candle and the candlestick of the day before. The earlier candlestick is green, tall, and has small shadows. The doji candle is also tailed by a gap between its lowest price point and the highest price point of the candle that comes next, which is red, tall and also has small shadows. The doji candle shadows must completely gap either below or above the shadows of the first and third day in order to have the abandoned baby pattern effect."
label.new(bar_index, patternLabelPosHigh, text="AB", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishAbandonedBaby)
C_TriStarBullishNumberOfCandles = 3
C_3DojisBullish = C_Doji[2] and C_Doji[1] and C_Doji
C_BodyGapUpBullish = C_BodyHi[1] < C_BodyLo
C_BodyGapDnBullish = C_BodyLo[1] > C_BodyHi
C_TriStarBullish = C_3DojisBullish and C_DownTrend[2] and C_BodyGapDnBullish[1] and C_BodyGapUpBullish
alertcondition(C_TriStarBullish, title = "Tri-Star – Bullish", message = "New Tri-Star – Bullish pattern detected")
if C_TriStarBullish and TriStarInput and (("Bullish" == CandleType) or CandleType == "Both")
var ttBullishTriStar = "三星看涨形态 Tri-Star\nA bullish TriStar candlestick pattern can form when three doji candlesticks materialize in immediate succession at the tail-end of an extended downtrend. The first doji candle marks indecision between bull and bear. The second doji gaps in the direction of the leading trend. The third changes the attitude of the market once the candlestick opens in the direction opposite to the trend. Each doji candle has a shadow, all comparatively shallow, which signify an interim cutback in volatility."
label.new(bar_index, patternLabelPosLow, text="3S", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishTriStar)
C_TriStarBearishNumberOfCandles = 3
C_3Dojis = C_Doji[2] and C_Doji[1] and C_Doji
C_BodyGapUp = C_BodyHi[1] < C_BodyLo
C_BodyGapDn = C_BodyLo[1] > C_BodyHi
C_TriStarBearish = C_3Dojis and C_UpTrend[2] and C_BodyGapUp[1] and C_BodyGapDn
alertcondition(C_TriStarBearish, title = "Tri-Star – Bearish", message = "New Tri-Star – Bearish pattern detected")
if C_TriStarBearish and TriStarInput and (("Bearish" == CandleType) or CandleType == "Both")
var ttBearishTriStar = "三星看跌形态 Tri-Star\nThis particular pattern can form when three doji candlesticks appear in immediate succession at the end of an extended uptrend. The first doji candle marks indecision between bull and bear. The second doji gaps in the direction of the leading trend. The third changes the attitude of the market once the candlestick opens in the direction opposite to the trend. Each doji candle has a shadow, all comparatively shallow, which signify an interim cutback in volatility."
label.new(bar_index, patternLabelPosHigh, text="3S", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishTriStar)
C_KickingBullishNumberOfCandles = 2
C_MarubozuShadowPercent = 5.0
C_Marubozu = C_LongBody and C_UpShadow <= C_MarubozuShadowPercent/100*C_Body and C_DnShadow <= C_MarubozuShadowPercent/100*C_Body
C_MarubozuWhiteBullishKicking = C_Marubozu and C_WhiteBody
C_MarubozuBlackBullish = C_Marubozu and C_BlackBody
C_KickingBullish = C_MarubozuBlackBullish[1] and C_MarubozuWhiteBullishKicking and high[1] < low
alertcondition(C_KickingBullish, title = "Kicking – Bullish", message = "New Kicking – Bullish pattern detected")
if C_KickingBullish and KickingInput and (("Bullish" == CandleType) or CandleType == "Both")
var ttBullishKicking = "看跌反冲 Kicking\nThe first day candlestick is a bearish marubozu candlestick with next to no upper or lower shadow and where the price opens at the day’s high and closes at the day’s low. The second day is a bullish marubozu pattern, with next to no upper or lower shadow and where the price opens at the day’s low and closes at the day’s high. Additionally, the second day gaps up extensively and opens above the opening price of the day before. This gap or window, as the Japanese call it, lies between day one and day two’s bullish candlesticks."
label.new(bar_index, patternLabelPosLow, text="K", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishKicking)
C_KickingBearishNumberOfCandles = 2
C_MarubozuBullishShadowPercent = 5.0
C_MarubozuBearishKicking = C_LongBody and C_UpShadow <= C_MarubozuBullishShadowPercent/100*C_Body and C_DnShadow <= C_MarubozuBullishShadowPercent/100*C_Body
C_MarubozuWhiteBearish = C_MarubozuBearishKicking and C_WhiteBody
C_MarubozuBlackBearishKicking = C_MarubozuBearishKicking and C_BlackBody
C_KickingBearish = C_MarubozuWhiteBearish[1] and C_MarubozuBlackBearishKicking and low[1] > high
alertcondition(C_KickingBearish, title = "Kicking – Bearish", message = "New Kicking – Bearish pattern detected")
if C_KickingBearish and KickingInput and (("Bearish" == CandleType) or CandleType == "Both")
var ttBearishKicking = "看跌反冲 Kicking\nA bearish kicking pattern will occur, subsequently signaling a reversal for a new downtrend. The first day candlestick is a bullish marubozu. The second day gaps down extensively and opens below the opening price of the day before. There is a gap between day one and two’s bearish candlesticks."
label.new(bar_index, patternLabelPosHigh, text="K", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishKicking)
var ttAllCandlestickPatterns = "All Candlestick Patterns\n"
label.new(bar_index, patternLabelPosLow, text="Collection", style=label.style_label_up, color = label_color_neutral, textcolor=color.white, tooltip = ttAllCandlestickPatterns)
Show all 554 lines