Pine Script: Three Black Crows Candlestick Pattern

Unlock powerful bearish trend reversal and continuation signals with this comprehensive guide to detecting and strategizing with Three Black Crows patterns in TradingView's Pine Script.

Posted: Expertise: Intermediate/Advanced

Why the Three Black Crows Pattern Matters in Pine Script

The Three Black Crows candlestick pattern is a strong three-candle bearish reversal or continuation pattern. It indicates a clear shift in market sentiment from buying to strong selling pressure. This pattern is characterized by three consecutive long bearish (red) candles that open within the body of the previous candle and close lower than the previous candle's close, ideally with small or no upper shadows. This demonstrates consistent bearish strength and makes Three Black Crows patterns invaluable for:

Understanding the Three Black Crows Candlestick Pattern

A Three Black Crows pattern consists of three specific, consecutive bearish candles:

  1. First Candle (Bearish): A long bearish (red) candle, ideally closing near its low, indicating initial selling strength.
  2. Second Candle (Bearish): A long bearish (red) candle that opens within the body of the first candle and closes lower than the first candle's close, ideally with little to no upper shadow.
  3. Third Candle (Bearish): Another long bearish (red) candle that opens within the body of the second candle and closes lower than the second candle's close, also ideally with little to no upper shadow.

This sequence demonstrates a sustained and powerful surge in selling activity, overcoming previous buying pressure.

Three Black Crows Pattern

Three consecutive long red candles, each opening within the previous body and closing lower, with small upper shadows.

Key Characteristics:

Basic Three Black Crows Pattern Detection in Pine Script

Here's how to create a basic indicator to detect Three Black Crows patterns in Pine Script v5:

//@version=5
indicator("Three Black Crows Detector", overlay=true)

// User input for minimum body size (as a percentage of ATR)
minBodySize = input.float(0.4, title="Min Body Size (ATR multiple)", minval=0.1, maxval=2.0)
// User input for maximum upper shadow size (as a percentage of body)
maxUpperShadowRatio = input.float(0.2, title="Max Upper Shadow Ratio (of Body)", minval=0.01, maxval=0.5)

// Helper function to check if a candle is a strong bearish candle with small upper shadow
isStrongBearish(idx) =>
    body = open[idx] - close[idx]
    upperShadow = high[idx] - math.max(open[idx], close[idx])
    
    body > ta.atr(14)[idx] * minBodySize and // Body is significant
    close[idx] < open[idx] and // It's a bearish candle
    upperShadow < body * maxUpperShadowRatio // Small upper shadow

// Check individual candle properties
isC1StrongBearish = isStrongBearish(2)
isC2StrongBearish = isStrongBearish(1)
isC3StrongBearish = isStrongBearish(0) // Current bar

// Check opening conditions
// open[1] should be lower than open[2] but higher than close[2]
isC2OpensInC1Body = open[1] < open[2] and open[1] > close[2]
// open[0] should be lower than open[1] but higher than close[1]
isC3OpensInC2Body = open[0] < open[1] and open[0] > close[1] // open[0] is current `open`

// Check lower closes
isC2ClosesLowerThanC1 = close[1] < close[2]
isC3ClosesLowerThanC2 = close[0] < close[1] // close[0] is current `close`

// Combine all criteria for Three Black Crows
isThreeBlackCrows = isC1StrongBearish and isC2StrongBearish and isC3StrongBearish and \
                    isC2OpensInC1Body and isC3OpensInC2Body and \
                    isC2ClosesLowerThanC1 and isC3ClosesLowerThanC2

// Plot signal on the chart
plotshape(isThreeBlackCrows, title="Three Black Crows", location=location.abovebar, color=color.new(color.maroon, 0), style=shape.triangledown, size=size.normal)

// Alert condition (optional)
alertcondition(isThreeBlackCrows, title="Three Black Crows Detected", message="Three Black Crows Pattern Detected!")

Advanced Three Black Crows Strategies

Combining Three Black Crows patterns with other indicators and market context provides stronger, more reliable signals for potential bearish moves.

1. Three Black Crows with Uptrend Reversal Confirmation (Using Moving Average)

//@version=5
strategy("Three Black Crows (Trend Reversal)", overlay=true)

// Input for Moving Average length (for trend detection)
maLength = input(50, "MA Length (for trend)")
ma = ta.ema(close, maLength) 

// Three Black Crows Pattern Detection (from basic example - simplified for brevity)
isC1StrongBearish = close[2] < open[2] and (open[2] - close[2]) > ta.atr(14)[2] * 0.4 
isC2StrongBearish = close[1] < open[1] and (open[1] - close[1]) > ta.atr(14)[1] * 0.4
isC3StrongBearish = close > open and (open - close) > ta.atr(14) * 0.4

isC2OpensInC1Body = open[1] < open[2] and open[1] > close[2]
isC3OpensInC2Body = open > open[1] and open < close[1] // open[0] is current `open`

isC2ClosesLowerThanC1 = close[1] < close[2]
isC3ClosesLowerThanC2 = close > close[1] // close[0] is current `close`

// Additional check for small upper shadows for robustness
isSmallUpperShadowC1 = (high[2] - math.max(open[2], close[2])) < (math.abs(open[2] - close[2]) * 0.2)
isSmallUpperShadowC2 = (high[1] - math.max(open[1], close[1])) < (math.abs(open[1] - close[1]) * 0.2)
isSmallUpperShadowC3 = (high - math.max(open, close)) < (math.abs(open - close) * 0.2) // Current bar's upper shadow

isThreeBlackCrows = isC1StrongBearish and isC2StrongBearish and isC3StrongBearish and \
                    isC2OpensInC1Body and isC3OpensInC2Body and \
                    isC2ClosesLowerThanC1 and isC3ClosesLowerThanC2 and \
                    isSmallUpperShadowC1 and isSmallUpperShadowC2 and isSmallUpperShadowC3

// Trend Confirmation: Pattern appears after a clear uptrend (price above MA)
isUptrend = close[3] > ma[3] and close[2] > ma[2] and close[1] > ma[1] // Check prior bars for uptrend context

// Strategy Logic with Trend Confirmation
shortSignal = isThreeBlackCrows and isUptrend

if (shortSignal)
    strategy.entry("Short", strategy.short)
    
// Plot MA
plot(ma, "Trend MA", color.blue)

// Plot confirmed signals
plotshape(shortSignal, title="Confirmed 3 Black Crows (Reversal)", location=location.abovebar, color=color.new(color.fuchsia, 0), style=shape.arrowdown, size=size.normal)

2. Three Black Crows with Volume Confirmation

//@version=5
indicator("Three Black Crows with Volume Confirmation", overlay=true)

// Three Black Crows Pattern Detection (from basic example - simplified)
isC1StrongBearish = close[2] < open[2] and (open[2] - close[2]) > ta.atr(14)[2] * 0.4 
isC2StrongBearish = close[1] < open[1] and (open[1] - close[1]) > ta.atr(14)[1] * 0.4
isC3StrongBearish = close < open and (open - close) > ta.atr(14) * 0.4

isC2OpensInC1Body = open[1] < open[2] and open[1] > close[2]
isC3OpensInC2Body = open < open[1] and open > close[1]

isC2ClosesLowerThanC1 = close[1] < close[2]
isC3ClosesLowerThanC2 = close < close[1]

isThreeBlackCrows = isC1StrongBearish and isC2StrongBearish and isC3StrongBearish and \
                    isC2OpensInC1Body and isC3OpensInC2Body and \
                    isC2ClosesLowerThanC1 and isC3ClosesLowerThanC2

// Volume Confirmation:
// Each bearish candle should have equal or increasing volume,
// and the third candle's volume should be significantly higher than average volume.
avgVolume = ta.sma(volume, 20) // 20-period Simple Moving Average of Volume
isVolumeConsistent = volume[2] <= volume[1] and volume[1] <= volume // Volume equal or increasing
isVolumeConfirmed = volume > avgVolume * 1.2 // Current volume is 1.2x average

// Combined signal
confirmedThreeBlackCrows = isThreeBlackCrows and isVolumeConsistent and isVolumeConfirmed

// Plot confirmed signals
barcolor(confirmedThreeBlackCrows ? color.new(color.purple, 60) : na)

plotshape(confirmedThreeBlackCrows, title="3 Black Crows (Vol Confirmed)", location=location.abovebar, color=color.new(color.red, 0), style=shape.labeldown, size=size.small, text="3BC Vol")

// Optional: Plot volume for visual check
plot(volume, title="Volume", color=color.gray, style=plot.style_columns)
plot(avgVolume, title="Avg Volume", color=color.orange, style=plot.style_line)

3. Three Black Crows with RSI Confirmation

//@version=5
indicator("Three Black Crows with RSI Confirmation", overlay=true)

// RSI Inputs
rsiLength = input(14, "RSI Length")
overbought = input(70, "RSI Overbought Level")

// Calculate RSI
rsiValue = ta.rsi(close, rsiLength)

// Three Black Crows Pattern Detection (simplified)
isC1StrongBearish = close[2] < open[2] and (open[2] - close[2]) > ta.atr(14)[2] * 0.4 
isC2StrongBearish = close[1] < open[1] and (open[1] - close[1]) > ta.atr(14)[1] * 0.4
isC3StrongBearish = close < open and (open - close) > ta.atr(14) * 0.4

isC2OpensInC1Body = open[1] < open[2] and open[1] > close[2]
isC3OpensInC2Body = open < open[1] and open > close[1]

isC2ClosesLowerThanC1 = close[1] < close[2]
isC3ClosesLowerThanC2 = close < close[1]

isThreeBlackCrows = isC1StrongBearish and isC2StrongBearish and isC3StrongBearish and \
                    isC2OpensInC1Body and isC3OpensInC2Body and \
                    isC2ClosesLowerThanC1 and isC3ClosesLowerThanC2

// RSI Confirmation: RSI falling from overbought territory or showing bearish divergence
rsiConfirmation = rsiValue < rsiValue[1] and rsiValue[1] < rsiValue[2] and rsiValue[2] >= overbought // RSI falling from overbought
// Or simpler: rsiValue <= overbought and rsiValue < rsiValue[1]

// Combined signal
signalThreeBlackCrows = isThreeBlackCrows and rsiConfirmation

// Plot signals
plotshape(signalThreeBlackCrows, title="3 Black Crows (RSI Confirmed)", location=location.abovebar, color=color.new(color.orange, 0), style=shape.arrowdown, size=size.normal)

// Plot RSI in a separate pane
plot(rsiValue, "RSI", color.blue, linewidth=2, display=display.pane)
hline(overbought, "Overbought", color.red)

Optimizing Three Black Crows Pattern Performance

To maximize the effectiveness of Three Black Crows patterns in your Pine Script strategies:

Common Three Black Crows Pattern Pitfalls to Avoid

Warning: Not every sequence of three red candles constitutes a valid "Three Black Crows" pattern. Strict adherence to criteria and contextual analysis are essential.

Conclusion

The Three Black Crows candlestick pattern is a powerful and visually clear signal for robust bearish price action. By understanding its precise three-candle formation, its contextual importance (especially after an uptrend), and integrating it with other technical confirmations like volume and momentum oscillators, you can leverage it effectively in your trading. Implementing Three Black Crows detection in Pine Script allows you to automate signal generation, combine it with complementary indicators for higher probability trades, and enhance your price action analysis to make more informed trading decisions on TradingView.