Home » Candlestick Patterns » Detecting Bearish Kicking Candlestick Pattern in Pine Script

Detecting Bearish Kicking Candlestick Pattern in Pine Script

Photo of author
Published on

Overview of Bearish Kicking Candlestick Pattern

The Bearish Kicking Candlestick Pattern is notable in the world of technical analysis and is often used by traders and analysts to predict potential reversals in market trends. It falls under the category of bearish reversal patterns and is known for its reliability and strong signal. Here’s a detailed overview:

Bearish Kicking Candlestick Pattern
  1. Formation and Structure: The Bearish Kicking pattern consists of two distinct candlesticks. The first is a bullish candle, typically green or white, indicating a day where the closing price was higher than the opening price. The second candlestick is what defines the pattern: it is a bearish candle, usually black or red, that opens at a lower price than the closing of the previous day and closes even lower. The critical aspect of this pattern is the gap between the two candlesticks, which signals a sudden shift in market sentiment.

Importance in Technical Analysis

The Bearish Kicking Candlestick Pattern holds significant importance in technical analysis for several reasons. Technical analysis, as a discipline, relies on the study of price charts and patterns to forecast future price movements. Within this context, the Bearish Kicking pattern offers unique insights:

  1. Strong Reversal Signal: One of the key strengths of the Bearish Kicking pattern is its role as a strong indicator of potential market reversals. When this pattern emerges, it often signals a shift from bullish to bearish sentiment, which can be crucial for traders and analysts in anticipating significant downturns in price.
  2. Market Psychology Insight: This pattern provides valuable insight into market psychology. The abrupt change from a bullish to a bearish candle, especially with a gap, reflects a sudden and significant shift in investor sentiment. This can indicate a loss of confidence among buyers and a strong takeover by sellers, which is vital information for understanding market dynamics.
  3. Enhanced Decision-Making: For traders and investors, the Bearish Kicking pattern can inform decision-making processes. Its appearance on a chart can serve as a trigger for selling or shorting a position, thus helping in portfolio management and risk mitigation.
  4. High Reliability: In the realm of candlestick patterns, the Bearish Kicking pattern is known for its high reliability. The clear and distinct formation (a gap followed by a bearish candlestick) reduces ambiguity, making it a more dependable signal compared to many other patterns.
  5. Complement to Other Tools: This pattern can be used in conjunction with other technical analysis tools, like trend lines, oscillators, and volume indicators, to confirm or refute the signals it provides. This integration enhances the overall analytical framework and can lead to more robust trading strategies.

Example From Trading View

Example From Trading View

Defining the Bearish Kicking Candlestick Pattern Criteria 

The Bearish Kicking Candlestick Pattern is defined by specific criteria that must be met for its formation. Understanding these criteria is crucial for accurately identifying this pattern in a chart. Here are the key elements that define the Bearish Kicking Candlestick Pattern:

  1. Two Distinct Candlesticks: The pattern consists of two candlesticks:
    • The first candlestick is bullish, typically represented in green or white. It indicates a day where the closing price is higher than the opening price.
    • The second candlestick is bearish, usually shown in red or black. This candlestick opens at a price lower than the previous day’s close and closes even lower.
  2. The Gap: A defining characteristic of the Bearish Kicking pattern is the gap between the two candlesticks. The bearish candlestick (second candle) must open at a lower price than the closing of the bullish candlestick (first candle), creating a gap in the chart. This gap is a critical element as it indicates a sudden shift in market sentiment.

Code For Detecting Bearish Kicking

//@version=5
indicator("Kicking - Bearish", shorttitle = "Kicking", overlay=true)
C_Len = 14 // ta.ema depth for bodyAvg
C_ShadowPercent = 5.0 // size of shadows
C_ShadowEqualsPercent = 100.0
C_DojiBodyPercent = 5.0
C_Factor = 2.0 // shows the number of times the shadow dominates the candlestick body

C_BodyHi = math.max(close, open)
C_BodyLo = math.min(close, open)
C_Body = C_BodyHi - C_BodyLo
C_BodyAvg = ta.ema(C_Body, C_Len)
C_SmallBody = C_Body < C_BodyAvg
C_LongBody = C_Body > C_BodyAvg
C_UpShadow = high - C_BodyHi
C_DnShadow = C_BodyLo - low
C_HasUpShadow = C_UpShadow > C_ShadowPercent / 100 * C_Body
C_HasDnShadow = C_DnShadow > C_ShadowPercent / 100 * C_Body
C_WhiteBody = open < close
C_BlackBody = open > close
C_Range = high-low
C_IsInsideBar = C_BodyHi[1] > C_BodyHi and C_BodyLo[1] < C_BodyLo
C_BodyMiddle = C_Body / 2 + C_BodyLo
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
C_IsDojiBody = C_Range > 0 and C_Body <= C_Range * C_DojiBodyPercent / 100
C_Doji = C_IsDojiBody and C_ShadowEquals

patternLabelPosLow = low - (ta.atr(30) * 0.6)
patternLabelPosHigh = high + (ta.atr(30) * 0.6)

label_color_bearish = input(color.red, "Label Color Bearish")
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 = "New pattern detected", message = "New Kicking – Bearish pattern detected")
if C_KickingBearish
    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="Kicking", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishKicking)
bgcolor(ta.highest(C_KickingBearish?1:0, C_KickingBearishNumberOfCandles)!=0 ? color.new(color.red, 90) : na, offset=-(C_KickingBearishNumberOfCandles-1))

Output

Output

Overview of the script 

1. Script Header

//@version=5
indicator("Kicking - Bearish", shorttitle = "Kicking", overlay=true)
  • //@version=5: Specifies that the script uses version 5 of Pine Script.
  • indicator(...): Defines the script as a custom indicator with the name “Kicking – Bearish”. The shorttitle is “Kicking” for brevity in the user interface, and overlay=true means this indicator will be drawn over the price chart.

2. Configuration Variables

C_Len = 14 // ta.ema depth for bodyAvg
C_ShadowPercent = 5.0 // size of shadows
C_ShadowEqualsPercent = 100.0
C_DojiBodyPercent = 5.0
C_Factor = 2.0 // shows the number of times the shadow dominates the candlestick body

These lines define various configuration variables used later in the script:

  • C_Len: Length of the Exponential Moving Average (EMA) for calculating the average body size of candlesticks.
  • C_ShadowPercent: Defines the minimum size of a candle’s shadow as a percentage of its body to consider it significant.
  • C_ShadowEqualsPercent: Used in defining a Doji candlestick (where the upper and lower shadows are approximately equal).
  • C_DojiBodyPercent: Defines the maximum body size of a Doji candlestick as a percentage of the total candlestick range.
  • C_Factor: Used in calculations where the dominance of the shadow over the candlestick body is considered.

3. Calculation of Candlestick Components

C_BodyHi = math.max(close, open)
C_BodyLo = math.min(close, open)
C_Body = C_BodyHi - C_BodyLo
C_BodyAvg = ta.ema(C_Body, C_Len)
C_SmallBody = C_Body < C_BodyAvg
C_LongBody = C_Body > C_BodyAvg
C_UpShadow = high - C_BodyHi
C_DnShadow = C_BodyLo - low
C_HasUpShadow = C_UpShadow > C_ShadowPercent / 100 * C_Body
C_HasDnShadow = C_DnShadow > C_ShadowPercent / 100 * C_Body
C_WhiteBody = open < close
C_BlackBody = open > close
C_Range = high-low
C_IsInsideBar = C_BodyHi[1] > C_BodyHi and C_BodyLo[1] < C_BodyLo
C_BodyMiddle = C_Body / 2 + C_BodyLo
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
C_IsDojiBody = C_Range > 0 and C_Body <= C_Range * C_DojiBodyPercent / 100
C_Doji = C_IsDojiBody and C_ShadowEquals
  • These lines calculate various characteristics of each candlestick on the chart. They determine the high and low of the candlestick body, whether the candlestick is long or short, the size of the upper and lower shadows, and if the candlestick is a Doji.

4. Pattern Label Positioning

patternLabelPosLow = low - (ta.atr(30) * 0.6)
patternLabelPosHigh = high + (ta.atr(30) * 0.6)
  • These lines calculate positions for placing labels on the chart. patternLabelPosLow and patternLabelPosHigh determine where to place labels relative to the high and low of the candlesticks, using the Average True Range (ATR) indicator to adjust the position dynamically.

5. User Inputs and Pattern Definition

label_color_bearish = input(color.red, "Label Color Bearish")
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
  • label_color_bearish: User input to choose the color of the label for bearish patterns.
  • C_KickingBearishNumberOfCandles: Defines the number of candles to consider for the pattern (2 in this case, as the Bearish Kicking pattern consists of two candlesticks).
  • C_MarubozuBullishShadowPercent: Sets a threshold for the shadow size to consider a candlestick as a Marubozu (a candlestick with little to no shadow).
  • C_MarubozuBearishKicking: Logic to define a Marubozu candlestick in the context of the Bearish Kicking pattern. It checks if the candlestick has a long body and very small shadows.
  • C_MarubozuWhiteBearish and C_MarubozuBlackBearishKicking: Determines if the Marubozu candlesticks are bullish (white) and bearish (black), respectively.
  • C_KickingBearish: The main logic to identify the Bearish Kicking pattern. It checks if there’s a bullish Marubozu candlestick followed by a bearish Marubozu candlestick with a gap down opening.

6. Alert and Labeling

alertcondition(C_KickingBearish, title = "New pattern detected", message = "New Kicking – Bearish pattern detected")
if C_KickingBearish
    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
if C_KickingBearish
    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="Kicking", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishKicking)
  • if C_KickingBearish: This conditional statement checks if the Bearish Kicking pattern is identified on the current candlestick.
  • var ttBearishKicking: Defines a tooltip text that explains the Bearish Kicking pattern. This text will be displayed when a user hovers over the label on the chart.
  • label.new(...): This function creates a new label on the chart. The label is positioned at patternLabelPosHigh, determined earlier, and contains the text “Kicking”. The label’s appearance is defined (downward pointing, red background, white text) and the tooltip text is assigned to it.

7. Background Coloring

bgcolor(ta.highest(C_KickingBearish?1:0, C_KickingBearishNumberOfCandles)!=0 ? color.new(color.red, 90) : na, offset=-(C_KickingBearishNumberOfCandles-1))
  • bgcolor(...): This function changes the background color of the chart to visually indicate the presence of the Bearish Kicking pattern.
  • ta.highest(...): This function checks if the Bearish Kicking pattern has occurred within the last C_KickingBearishNumberOfCandles candles.
  • color.new(color.red, 90): If the pattern is found, the background color is set to a semi-transparent red, indicating a bearish signal. If not, no background color is applied (na).

Frequently Asked Questions

What does this code detect?

It identifies the Bearish Kicking Candlestick Pattern, a bearish reversal indicator, by analyzing candlestick formations on charts.

Can it be used on different time frames or instruments?

Yes, it works on various time frames and financial instruments like stocks, forex, and commodities.

How does the script indicate the detection of this pattern?

The script marks the pattern with a label and changes the background color on the chart for visual indication.

Can I adjust the detection parameters?

Yes, the script allows customization of parameters like shadow percent and body size for tailored sensitivity.

Does the script provide alerts for pattern detection?

Yes, it includes an alert function that notifies users when the pattern is detected.

Conclusion

This Pine Script code identifies the Bearish Kicking Candlestick Pattern, a notable bearish reversal indicator in technical analysis. Designed for versatility, it can be applied to various financial instruments and time frames, making it a valuable tool for diverse trading strategies. With customizable parameters, the script allows traders to fine-tune its sensitivity to align with their individual analysis requirements. The visual cues and alert functionality enhance its practicality, providing timely indications of potential market reversals. This script is a significant aid for traders who incorporate candlestick patterns into their technical analysis arsenal, offering a blend of precision and adaptability in market trend analysis.

Leave a Comment