Why the Evening Star Pattern Matters in Pine Script
The Evening Star candlestick pattern is a powerful three-candle bearish reversal pattern that typically forms after an uptrend. It signals a potential top and a strong shift in momentum from buyers to sellers. This pattern indicates that buyers were dominant initially, but their power waned, leading to indecision, and then sellers took control, pushing prices significantly lower. This makes Evening Star patterns invaluable for:
- Identifying potential bearish trend reversals at key resistance levels.
- Signaling exhaustion in an uptrend.
- Generating high-probability entry signals for short positions.
Understanding the Evening Star Candlestick Pattern
An Evening Star pattern consists of three specific candles:
- First Candle (Bullish): A long bullish (green) candle, indicating strong buying pressure and a continuation of the uptrend.
- Second Candle (Star/Doji): A small-bodied candle (a doji or a spinning top, can be bullish or bearish) that gaps up from the first candle's close. This candle represents indecision in the market, often appearing at the peak of the rally.
- Third Candle (Bearish): A long bearish (red) candle that gaps down from the second candle and closes well into (ideally below the midpoint) of the first bullish candle's body. This signifies that sellers have taken control and reversed the prior upward momentum.
The overall structure indicates a progression from buying dominance to indecision, followed by a strong bearish takeover.
Evening Star Pattern
A long green candle, followed by a small star candle (often with a gap up), then a large red candle that pushes back into the first candle's body.
- Candle 1: Long bullish candle.
- Candle 2 (Star): Small body (spinning top or doji), closes above Candle 1's close. Its real body does not overlap with Candle 1's real body.
- Candle 3: Long bearish candle that opens below Candle 2's close and closes significantly into the real body of Candle 1.
- Context: Most significant when appearing at the top of a clear uptrend.
Basic Evening Star Pattern Detection in Pine Script
Here's how to create a basic indicator to detect Evening Star patterns in Pine Script v5:
//@version=5
indicator("Evening Star Pattern Detector", overlay=true)
// Candle 1 (previous-previous bar) - Long Bullish
isC1Bullish = close[2] > open[2]
isC1Long = (close[2] - open[2]) > ta.atr(10)[2] * 0.5 // Body is significant, e.g., > 0.5 ATR
// Candle 2 (previous bar) - Small Body (Star) and Gaps Up
isC2SmallBody = math.abs(close[1] - open[1]) <= (high[1] - low[1]) * 0.3 // Small body, e.g., <= 30% of range
isC2GapsUp = open[1] > close[2] // Gap up from previous candle's close
isC2Star = isC2SmallBody and isC2GapsUp
// Candle 3 (current bar) - Long Bearish and Gaps Down, closing into C1 body
isC3Bearish = close < open
isC3Long = (open - close) > ta.atr(10) * 0.5 // Body is significant
isC3GapsDown = open < low[1] // Gaps down from previous candle's low
isC3ClosesIntoC1 = close < (open[2] + close[2]) / 2 // Closes below midpoint of C1 body
// Combine all criteria for Evening Star
isEveningStar = isC1Bullish and isC1Long and isC2Star and isC3Bearish and isC3Long and isC3GapsDown and isC3ClosesIntoC1
// Plot signal on the chart
plotshape(isEveningStar, title="Evening Star", location=location.abovebar, color=color.new(color.maroon, 0), style=shape.triangledown, size=size.normal)
// Alert condition (optional)
alertcondition(isEveningStar, title="Evening Star Detected", message="Evening Star Candlestick Pattern Detected!")
Advanced Evening Star Strategies
Combining Evening Star patterns with other indicators and market context provides stronger, more reliable signals for potential bearish reversals.
1. Evening Star with Uptrend Confirmation (Using Moving Average)
//@version=5
strategy("Evening Star with Trend Confirmation", overlay=true)
// Input for Moving Average length
maLength = input(50, "MA Length (for trend)")
ma = ta.ema(close, maLength) // Using EMA for uptrend detection
// Evening Star Pattern Detection (from basic example)
isC1Bullish = close[2] > open[2]
isC1Long = (close[2] - open[2]) > ta.atr(10)[2] * 0.5
isC2SmallBody = math.abs(close[1] - open[1]) <= (high[1] - low[1]) * 0.3
isC2GapsUp = open[1] > close[2]
isC2Star = isC2SmallBody and isC2GapsUp
isC3Bearish = close < open
isC3Long = (open - close) > ta.atr(10) * 0.5
isC3GapsDown = open < low[1]
isC3ClosesIntoC1 = close < (open[2] + close[2]) / 2
isEveningStar = isC1Bullish and isC1Long and isC2Star and isC3Bearish and isC3Long and isC3GapsDown and isC3ClosesIntoC1
// Trend Confirmation: Price should be above the MA (uptrend)
// AND the MA itself should be sloping upwards (optional, but stronger)
isUptrend = close > ma and ma > ma[1]
// Strategy Logic with Trend Confirmation
shortSignal = isEveningStar and isUptrend
if (shortSignal)
strategy.entry("Short", strategy.short)
// Plot MA
plot(ma, "Trend MA", color.blue)
// Plot confirmed signals
plotshape(shortSignal, title="Confirmed Evening Star", location=location.abovebar, color=color.new(color.fuchsia, 0), style=shape.arrowdown, size=size.normal)
2. Evening Star with Volume Confirmation
//@version=5
indicator("Evening Star with Volume Confirmation", overlay=true)
// Evening Star Pattern Detection (from basic example)
isC1Bullish = close[2] > open[2]
isC1Long = (close[2] - open[2]) > ta.atr(10)[2] * 0.5
isC2SmallBody = math.abs(close[1] - open[1]) <= (high[1] - low[1]) * 0.3
isC2GapsUp = open[1] > close[2]
isC2Star = isC2SmallBody and isC2GapsUp
isC3Bearish = close < open
isC3Long = (open - close) > ta.atr(10) * 0.5
isC3GapsDown = open < low[1]
isC3ClosesIntoC1 = close < (open[2] + close[2]) / 2
isEveningStar = isC1Bullish and isC1Long and isC2Star and isC3Bearish and isC3Long and isC3GapsDown and isC3ClosesIntoC1
// Volume Confirmation:
// Volume on the third bearish candle should be higher than average volume
avgVolume = ta.sma(volume, 20) // 20-period Simple Moving Average of Volume
isVolumeConfirmed = volume > avgVolume * 1.5 // Volume is 1.5x average
// Combined signal
confirmedEveningStar = isEveningStar and isVolumeConfirmed
// Plot confirmed signals
barcolor(confirmedEveningStar ? color.new(color.purple, 60) : na)
plotshape(confirmedEveningStar, title="Evening Star (Vol Confirmed)", location=location.abovebar, color=color.new(color.red, 0), style=shape.labeldown, size=size.small, text="ES 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. Evening Star with RSI Confirmation
//@version=5
indicator("Evening Star 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)
// Evening Star Pattern Detection
isC1Bullish = close[2] > open[2]
isC1Long = (close[2] - open[2]) > ta.atr(10)[2] * 0.5
isC2SmallBody = math.abs(close[1] - open[1]) <= (high[1] - low[1]) * 0.3
isC2GapsUp = open[1] > close[2]
isC2Star = isC2SmallBody and isC2GapsUp
isC3Bearish = close < open
isC3Long = (open - close) > ta.atr(10) * 0.5
isC3GapsDown = open < low[1]
isC3ClosesIntoC1 = close < (open[2] + close[2]) / 2
isEveningStar = isC1Bullish and isC1Long and isC2Star and isC3Bearish and isC3Long and isC3GapsDown and isC3ClosesIntoC1
// RSI Confirmation: RSI should be in overbought territory or falling from it
rsiConfirmation = rsiValue >= overbought or (rsiValue[1] >= overbought and rsiValue < rsiValue[1])
// Combined signal
signalEveningStar = isEveningStar and rsiConfirmation
// Plot signals
plotshape(signalEveningStar, title="Evening Star (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 Evening Star Pattern Performance
To maximize the effectiveness of Evening Star patterns in your Pine Script strategies:
- Confirm Uptrend: The Evening Star is a bearish reversal pattern, so it's most reliable when it appears after a clear uptrend. Avoid trading it in a downtrend or sideways market.
- Volume Confirmation: Look for a significant increase in volume, especially on the third bearish candle, as it indicates strong selling interest and adds conviction to the reversal signal.
- Resistance Levels: Evening Star patterns that form at significant resistance levels (e.g., previous highs, strong moving averages, Fibonacci retracement levels) tend to be more powerful and reliable.
- Gaps: The presence of gaps (up before the star, down after the star) strengthens the pattern, showing strong shifts in sentiment.
- Timeframe: While visible on all timeframes, signals on higher timeframes (e.g., daily, weekly) generally carry more weight and are considered more reliable for sustained reversals.
Common Evening Star Pattern Pitfalls to Avoid
- Ignoring Trend Context: An Evening Star is a reversal pattern; if it appears in a downtrend or ranging market, its predictive power is significantly diminished.
- Lack of Gaps: While not always mandatory, the absence of gaps can weaken the pattern's reliability, especially for the second candle.
- Small Third Candle: If the third candle is small or doesn't close substantially into the body of the first bullish candle, it indicates a weaker bearish conviction.
- Low Volume Confirmation: A lack of significant volume on the third bearish candle may suggest the reversal is not supported by strong selling interest.
- Over-reliance: Using the Evening Star pattern in isolation without confirmation from other indicators, resistance levels, or broader market analysis can lead to false signals.
Conclusion
The Evening Star candlestick pattern is a well-regarded and visually clear signal for bearish reversals. By understanding its precise three-candle formation, its contextual importance within an uptrend, and integrating it with other technical confirmations, you can leverage it effectively in your trading. Implementing Evening Star 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.
Enhance Your Trading
Get a high-performance Pine Script analysis tool for actionable market insights, designed for traders on the move.
This strategy runs in live mode on TradingView, helping you identify potential opportunities.
Subscribe now @ $99/month