Home » Candlestick Patterns » Detecting Bullish Stick Sandwich Candlestick Pattern in Pine Script

Detecting Bullish Stick Sandwich Candlestick Pattern in Pine Script

Photo of author
Published on

Overview of Bullish Stick Sandwich Candlestick Pattern

The Bullish Stick Sandwich Candlestick Pattern is a distinctive formation in technical analysis, often signaling a bullish reversal. Here’s an overview of its key characteristics:

Overview of Bullish Stick Sandwich Candlestick Pattern
  1. Formation and Structure:
    • The pattern consists of three candles: two black (or red) candles sandwiching a white (or green) candle.
    • The first and third candles are bearish, showing a closing price lower than the opening price.
    • The middle candle is bullish, with a closing price higher than its opening price.
  2. Closing Prices Alignment:
    • A critical aspect of this pattern is that the closing prices of the first and third candles are approximately at the same level, indicating a potential exhaustion of the bearish trend.

Importance in Technical Analysis

The Bullish Stick Sandwich Candlestick Pattern holds significant importance in technical analysis for several key reasons:

  1. Bullish Reversal Indicator: It serves as a potential signal for a bullish reversal, especially when it appears in a downtrend. This can alert traders to a possible shift in market direction from bearish to bullish.
  2. Insight into Market Sentiment: The pattern reflects a tug-of-war between buyers and sellers, where the temporary gain by bulls (in the middle candle) is countered by bears, but without significant progress. This stalemate can signal weakening bearish momentum.
  3. Enhances Trading Strategy: Incorporating the Bullish Stick Sandwich pattern into a trading strategy can aid in making informed decisions about entry and exit points. It’s particularly useful for traders looking to identify bottoms or to initiate long positions.
  4. Confirmation of Other Indicators: When this pattern aligns with other bullish indicators or technical signals (like support levels or bullish divergence in oscillators), it can provide a stronger case for a bullish market outlook.
  5. Risk Management: Recognizing this pattern can help traders in managing risk, particularly by setting stop-loss orders more effectively or adjusting their portfolio to mitigate potential losses.

Example From Trading View

Example From Trading View

Defining the Bullish Stick Sandwich Candlestick Pattern Criteria

The Bullish Stick Sandwich Candlestick Pattern is defined by a specific set of criteria that signal a potential bullish reversal in the market. Here are the key criteria that characterize this pattern:

  1. Three-Candle Formation:
    • The pattern consists of three candles: two bearish (black or red) candles surrounding a central bullish (white or green) candle.
  2. Trend Context:
    • It typically appears during a downtrend, indicating a potential reversal to an uptrend.
  3. First Candle:
    • The first candle is bearish, showing a close lower than its open, contributing to the ongoing downtrend.
  4. Middle Candle:
    • The middle candle is bullish, with a close higher than its open. This candle interrupts the downtrend, but not significantly enough to change the trend on its own.
  5. Third Candle:
    • The third candle is again bearish, closing around the same level as the first candle’s close. This creates a ‘sandwich’ effect.

Code For Detecting Bullish Stick Sandwich

//@version=5
indicator("Bullish Stick Sandwich Pattern", shorttitle="BSSP", overlay=true)

// Function to check if a candle is black (down) or white (up)
isBlackCandle(close, open) =>
    close < open

isWhiteCandle(close, open) =>
    close > open

// Criteria for Bullish Stick Sandwich
firstCandleBlack = isBlackCandle(close[2], open[2])
middleCandleWhite = isWhiteCandle(close[1], open[1])
lastCandleBlack = isBlackCandle(close, open)

closingPricesNear = math.abs(close[2] - close) < ((high[2] - low[2]) * 0.1)
middleCandleContained = low[1] > low[2] and high[1] < high[2] and low[1] > low and high[1] < high

// Detecting the pattern
bullishStickSandwich = firstCandleBlack and middleCandleWhite and lastCandleBlack and closingPricesNear and middleCandleContained

// Plotting the label
if bullishStickSandwich
    label.new(bar_index[1], low[1], "Bullish Stick\nSandwich", color=color.rgb(0, 255, 8),yloc = yloc.abovebar)

Output

Output

Overview of the script 

1. Script Declaration

//@version=5
indicator("Bullish Stick Sandwich Pattern", shorttitle="BSSP", overlay=true)
  • //@version=5: Specifies that the script is written in Pine Script version 5.
  • indicator(...): Declares a new indicator with the name “Bullish Stick Sandwich Pattern”, a short title “BSSP”, and overlay=true indicates that the indicator will be plotted on the main price chart.

2. Function Definitions for Candle Types

isBlackCandle(close, open) =>
    close < open

isWhiteCandle(close, open) =>
    close > open
  • isBlackCandle: A function to determine if a candle is black (bearish), which is true when the closing price is lower than the opening price.
  • isWhiteCandle: A function to check if a candle is white (bullish), true when the closing price is higher than the opening price.

3. Criteria for Bullish Stick Sandwich

firstCandleBlack = isBlackCandle(close[2], open[2])
middleCandleWhite = isWhiteCandle(close[1], open[1])
lastCandleBlack = isBlackCandle(close, open)

These lines define the core pattern criteria: the first and last candles should be black (bearish), and the middle candle should be white (bullish).

4. Additional Pattern Conditions

closingPricesNear = math.abs(close[2] - close) < ((high[2] - low[2]) * 0.1)
middleCandleContained = low[1] > low[2] and high[1] < high[2] and low[1] > low and high[1] < high
  • closingPricesNear: Checks if the closing prices of the first and last candles are close to each other, within 10% of the range of the first candle.
  • middleCandleContained: Ensures the middle candle is contained within the range of the first and last candles.

5. Detecting the Pattern

bullishStickSandwich = firstCandleBlack and middleCandleWhite and lastCandleBlack and closingPricesNear and middleCandleContained
  • This line combines all the conditions to identify the Bullish Stick Sandwich pattern.

6. Plotting the Label

bullishStickSandwich = firstCandleBlack and middleCandleWhite and lastCandleBlack and closingPricesNear and middleCandleContained
  • This conditional statement checks if the bullishStickSandwich pattern is true.
  • label.new(...): If the pattern is detected, this function plots a label on the chart.
  • bar_index[1], low[1]: The label is positioned at the low of the middle candle.
  • The label text is “Bullish Stick\nSandwich”, with a green color, placed above the bar.

Frequently Asked Questions

What does the Bullish Stick Sandwich Pine Script identify?

It detects the Bullish Stick Sandwich pattern, a potential bullish reversal signal in a downtrend.

What are the key components of this pattern in the script?

Two black (bearish) candles sandwiching a white (bullish) candle with similar closing prices for the black candles.

Can I modify the script for different trading instruments?

Yes, parameters like the ATR length can be adjusted to suit various instruments and volatility levels.

Is this script suitable for all time frames?

Yes, it can be applied to any time frame, but effectiveness may vary depending on market conditions.

Does the script provide visual indicators on the chart?

Yes, it plots a label on the chart where the Bullish Stick Sandwich pattern is identified.

Conclusion

This script is designed for detecting the Bullish Stick Sandwich Candlestick Pattern, It efficiently automates the recognition of this pattern, which is characterized by two bearish candles flanking a central bullish candle, with the closing prices of the bearish candles being nearly equal. The script enhances trading analysis by providing quick and accurate identification of this pattern, aiding traders in pinpointing potential reversal points in a downtrend. Its integration into trading strategies offers a valuable tool for market analysis, especially for those who rely on candlestick patterns to guide their trading decisions.

Leave a Comment