Home » Candlestick Patterns » Detecting Bearish Homing Pigeon Candlestick Pattern in Pine Script

Detecting Bearish Homing Pigeon Candlestick Pattern in Pine Script

Photo of author
Published on

Overview of Bearish Homing Pigeon Candlestick Pattern

The “Bearish Homing Pigeon” is not a standard term in traditional candlestick pattern terminology. Typically, the term “Homing Pigeon” refers to a bullish reversal pattern. However, if we were to conceptualize a “Bearish Homing Pigeon” pattern by mirroring the principles of the Bullish Homing Pigeon, it would be characterized as follows:

Bearish Homing Pigeon Candlestick Pattern

Definition and Structure

  • Formation: This hypothetical pattern would consist of two consecutive candlesticks appearing during an uptrend.
  • Appearance:
    • First Candle: A large, bullish (green or white) candle, signifying a strong upward move.
    • Second Candle: A smaller bullish candle, completely engulfed within the body of the first candle.
  • Color: Both candles typically show that the closing price is higher than the opening price.

Importance in Technical Analysis

Example From Trading View

Example From Trading View

Defining the Bearish Homing Pigeon Candlestick Pattern Criteria

  1. Two-Candle Formation: The pattern consists of two consecutive candlesticks that appear during an uptrend or a bullish pullback.
  2. Large Bullish Candle: The first candle is a large, bullish one, indicating a strong upward price movement. The color of the candle is typically green or white, showing that the closing price is higher than the opening price.
  3. Smaller Bullish Candle: The second candle is smaller in comparison to the first candle. It is also bullish (green or white), suggesting that the closing price is again higher than the opening price.
  4. Engulfed by the First Candle: The body of the second candle is completely contained within the vertical range of the body of the first candle. This means that the high and low prices of the second candle are within the high and low of the first candle’s body.
  5. Indication of Weakening Uptrend: The pattern indicates that the bullish sentiment is losing its momentum. The small size of the second candle suggests a reduction in buying pressure, hinting at a potential continuation of the uptrend with caution or a pause in the upward trend.

Code For Detecting Bearish Homing Pigeon

//@version=5
indicator("Bearish Homing Pigeon Pattern", shorttitle="BHP", overlay=true)

// Define the Bearish Homing Pigeon criteria
isBearishHomingPigeon() =>
    // Criteria for the first (larger) candle
    bullish1 = close[1] > open[1]
    body1 = math.abs(close[1] - open[1])

    // Criteria for the second (smaller) candle
    bullish2 = close > open
    body2 = math.abs(close - open)

    // The second candle's body is within the first candle's range
    withinFirstCandle = low >= low[1] and high <= high[1] and close[1] > close

    // The second candle is smaller than the first
    smallerBody = body2 < body1

    // Overall pattern criteria
    bullish1 and bullish2 and withinFirstCandle and smallerBody

// Plotting
if isBearishHomingPigeon()
    label.new(bar_index[1], high[1], "Bearish Homing Pigeon", color=color.red, textcolor=color.white, style=label.style_label_down, yloc=yloc.abovebar)

Output

Output

Overview of the script 

1. Script Declaration

//@version=5
indicator("Bearish Homing Pigeon Pattern", shorttitle="BHP", overlay=true)
  • //@version=5: Indicates that the script is written in Pine Script version 5.
  • indicator(...): Declares the script as a custom indicator, named “Bearish Homing Pigeon Pattern” with the abbreviation “BHP”. The overlay=true parameter specifies that the indicator will be plotted directly on the price chart.

2. Function Definition

isBearishHomingPigeon() =>
  • isBearishHomingPigeon() =>: This line defines a function called isBearishHomingPigeon. The function will contain the logic to identify the Bearish Homing Pigeon pattern.

3. First Candle Criteria

    bullish1 = close[1] > open[1]
    body1 = math.abs(close[1] - open[1])
  • bullish1 = close[1] > open[1]: Checks if the first (previous) candle is bullish. It compares the closing price (close[1]) with the opening price (open[1]) of the first candle. If the close is higher than the open, the candle is bullish.
  • body1 = math.abs(close[1] - open[1]): Calculates the absolute size of the first candle’s body, representing the difference between the opening and closing prices.

4. Second Candle Criteria

    bullish2 = close > open
    body2 = math.abs(close - open)
    withinFirstCandle = low >= low[1] and high <= high[1] and close[1] > close
    smallerBody = body2 < body1
  • bullish2 = close > open: Similar to bullish1, this checks if the current (second) candle is bullish.
  • body2 = math.abs(close - open): Calculates the absolute size of the second candle’s body.
  • withinFirstCandle = low >= low[1] and high <= high[1] and close[1] > close: Ensures the second candle’s body is entirely within the range of the first candle’s body, including the additional condition that the first candle’s close is greater than the second’s close.
  • smallerBody = body2 < body1: Verifies that the body of the second candle is smaller than the body of the first candle.

5. Overall Pattern Criteria

    bullish1 and bullish2 and withinFirstCandle and smallerBody
  • This line combines all individual criteria, returning true if both candles are bullish, the second candle’s body is fully within the first candle’s range, and the second candle’s body is smaller than the first’s.

6. Plotting the Pattern

if isBearishHomingPigeon()
    label.new(bar_index[1], high[1], "Bearish Homing Pigeon", color=color.red, textcolor=color.white, style=label.style_label_down, yloc=yloc.abovebar)
  • if isBearishHomingPigeon(): This conditional statement checks if the isBearishHomingPigeon function returns true, indicating the detection of the pattern.
  • label.new(...): This creates a new label on the chart. The label is positioned at the bar index of the first candle (bar_index[1]) and above the highest price of the first candle (high[1]). The label displays “Bearish Homing Pigeon” with a red background and white text. It is styled to point downwards and is positioned above the bar.

Frequently Asked Questions

What does the Bearish Homing Pigeon pattern indicate in this script?

The script detects a scenario where, during an uptrend, a smaller bullish candle is completely engulfed by a larger bullish candle, potentially indicating a continuation of the uptrend but with caution due to decreasing momentum.

How does the script define a bullish candle?

A candle is considered bullish if its closing price is higher than its opening price, represented in the code by close > open.

Why does the script place labels above the bar for the Bearish Homing Pigeon pattern?

Labels are placed above the bar to visually highlight where the pattern occurs, making it easier for traders to identify and analyze these patterns on the chart.

Can this script be used for automated trading strategies?

While the script can identify the pattern, it’s advisable to use it as part of a broader strategy with additional indicators for confirmation, rather than relying on it solely for automated trading decisions.

Is the Bearish Homing Pigeon pattern a reliable indicator of trend continuation?

The pattern suggests potential trend continuation but with weakened momentum. However, it should be used with caution and in conjunction with other technical analysis tools, as it’s not a standard pattern and may not always be a reliable indicator on its own.

Conclusion

The Pine Script designed for the hypothetical Bearish Homing Pigeon pattern in TradingView serves as a unique tool in the realm of technical analysis. This script, tailored to detect a specific candlestick formation, automates the identification of a pattern consisting of two bullish candles within an uptrend. The key feature of this pattern is the second, smaller candle being fully engulfed by the body of the first, larger candle, symbolizing a potential weakening in bullish momentum. The script functions by analyzing each candlestick’s open and close prices to determine their bullish nature. It then compares the size and range of these candlesticks to identify the engulfing relationship. When these criteria are met, the script generates a visual label on the chart. This label, displayed above the first candle, serves as a clear and immediate indicator of the pattern’s occurrence, aiding traders in quickly recognizing potential shifts in market dynamics.

Leave a Comment