Why the Morning Star Pattern Matters in Pine Script
The Morning Star candlestick pattern is a powerful three-candle bullish reversal pattern that typically forms after a downtrend. It signals a potential bottom and a strong shift in momentum from sellers to buyers. This pattern indicates that sellers were dominant initially, but their power waned, leading to indecision, and then buyers took control, pushing prices significantly higher. This makes Morning Star patterns invaluable for:
- Identifying potential bullish trend reversals at key support levels.
- Signaling exhaustion in a downtrend.
- Generating high-probability entry signals for long positions.
Understanding the Morning Star Candlestick Pattern
A Morning Star pattern consists of three specific candles:
- First Candle (Bearish): A long bearish (red) candle, indicating strong selling pressure and a continuation of the downtrend.
- Second Candle (Star/Doji): A small-bodied candle (a doji or a spinning top, can be bullish or bearish) that gaps down from the first candle's close. This candle represents indecision in the market.
- Third Candle (Bullish): A long bullish (green) candle that gaps up from the second candle and closes well into (ideally above the midpoint) of the first bearish candle's body. This signifies that buyers have taken control.
The overall structure indicates a progression from selling dominance to indecision, followed by a strong bullish takeover.
Morning Star Pattern
A long red candle, followed by a small star candle (often with a gap down), then a large green candle that pushes back into the first candle's body.
- Candle 1: Long bearish candle.
- Candle 2 (Star): Small body (spinning top or doji), closes below Candle 1's close. Its real body does not overlap with Candle 1's real body.
- Candle 3: Long bullish candle that opens above Candle 2's close and closes significantly into the real body of Candle 1.
- Context: Most significant when appearing at the bottom of a clear downtrend.
Basic Morning Star Pattern Detection in Pine Script
Here's how to create a basic indicator to detect Morning Star patterns in Pine Script v5:
//@version=5
indicator("Morning Star Pattern Detector", overlay=true)
// Candle 1 (previous-previous bar) - Long Bearish
isC1Bearish = close[2] < open[2]
isC1Long = (open[2] - close[2]) > ta.atr(10)[2] * 0.5 // Body is significant, e.g., > 0.5 ATR
// Candle 2 (previous bar) - Small Body (Star) and Gaps Down
isC2SmallBody = math.abs(close[1] - open[1]) <= (high[1] - low[1]) * 0.3 // Small body, e.g., <= 30% of range
isC2GapsDown = open[1] < close[2] // Gap down from previous candle's close
isC2Star = isC2SmallBody and isC2GapsDown
// Candle 3 (current bar) - Long Bullish and Gaps Up, closing into C1 body
isC3Bullish = close > open
isC3Long = (close - open) > ta.atr(10) * 0.5 // Body is significant
isC3GapsUp = open > high[1] // Gaps up from previous candle's high
isC3ClosesIntoC1 = close > (open[2] + close[2]) / 2 // Closes above midpoint of C1 body
// Combine all criteria for Morning Star
isMorningStar = isC1Bearish and isC1Long and isC2Star and isC3Bullish and isC3Long and isC3GapsUp and isC3ClosesIntoC1
// Plot signal on the chart
plotshape(isMorningStar, title="Morning Star", location=location.belowbar, color=color.new(color.fuchsia, 0), style=shape.triangleup, size=size.normal)
// Alert condition (optional)
alertcondition(isMorningStar, title="Morning Star Detected", message="Morning Star Candlestick Pattern Detected!")
Advanced Morning Star Strategies
Combining Morning Star patterns with other indicators and market context provides stronger, more reliable signals for potential bullish reversals.
1. Morning Star with Downtrend Confirmation (Using Moving Average)
//@version=5
strategy("Morning 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 downtrend detection
// Morning Star Pattern Detection (from basic example)
isC1Bearish = close[2] < open[2]
isC1Long = (open[2] - close[2]) > ta.atr(10)[2] * 0.5
isC2SmallBody = math.abs(close[1] - open[1]) <= (high[1] - low[1]) * 0.3
isC2GapsDown = open[1] < close[2]
isC2Star = isC2SmallBody and isC2GapsDown
isC3Bullish = close > open
isC3Long = (close - open) > ta.atr(10) * 0.5
isC3GapsUp = open > high[1]
isC3ClosesIntoC1 = close > (open[2] + close[2]) / 2
isMorningStar = isC1Bearish and isC1Long and isC2Star and isC3Bullish and isC3Long and isC3GapsUp and isC3ClosesIntoC1
// Trend Confirmation: Price should be below the MA (downtrend)
// AND the MA itself should be sloping downwards (optional, but stronger)
isDowntrend = close < ma and ma < ma[1]
// Strategy Logic with Trend Confirmation
longSignal = isMorningStar and isDowntrend
if (longSignal)
strategy.entry("Long", strategy.long)
// Plot MA
plot(ma, "Trend MA", color.blue)
// Plot confirmed signals
plotshape(longSignal, title="Confirmed Morning Star", location=location.belowbar, color=color.new(color.navy, 0), style=shape.arrowup, size=size.normal)
2. Morning Star with Volume Confirmation
//@version=5
indicator("Morning Star with Volume Confirmation", overlay=true)
// Morning Star Pattern Detection (from basic example)
isC1Bearish = close[2] < open[2]
isC1Long = (open[2] - close[2]) > ta.atr(10)[2] * 0.5
isC2SmallBody = math.abs(close[1] - open[1]) <= (high[1] - low[1]) * 0.3
isC2GapsDown = open[1] < close[2]
isC2Star = isC2SmallBody and isC2GapsDown
isC3Bullish = close > open
isC3Long = (close - open) > ta.atr(10) * 0.5
isC3GapsUp = open > high[1]
isC3ClosesIntoC1 = close > (open[2] + close[2]) / 2
isMorningStar = isC1Bearish and isC1Long and isC2Star and isC3Bullish and isC3Long and isC3GapsUp and isC3ClosesIntoC1
// Volume Confirmation:
// Volume on the third bullish 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
confirmedMorningStar = isMorningStar and isVolumeConfirmed
// Plot confirmed signals
barcolor(confirmedMorningStar ? color.new(color.aqua, 60) : na)
plotshape(confirmedMorningStar, title="Morning Star (Vol Confirmed)", location=location.belowbar, color=color.new(color.green, 0), style=shape.labelup, size=size.small, text="MS 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. Morning Star with RSI Confirmation
//@version=5
indicator("Morning Star with RSI Confirmation", overlay=true)
// RSI Inputs
rsiLength = input(14, "RSI Length")
oversold = input(30, "RSI Oversold Level")
// Calculate RSI
rsiValue = ta.rsi(close, rsiLength)
// Morning Star Pattern Detection
isC1Bearish = close[2] < open[2]
isC1Long = (open[2] - close[2]) > ta.atr(10)[2] * 0.5
isC2SmallBody = math.abs(close[1] - open[1]) <= (high[1] - low[1]) * 0.3
isC2GapsDown = open[1] < close[2]
isC2Star = isC2SmallBody and isC2GapsDown
isC3Bullish = close > open
isC3Long = (close - open) > ta.atr(10) * 0.5
isC3GapsUp = open > high[1]
isC3ClosesIntoC1 = close > (open[2] + close[2]) / 2
isMorningStar = isC1Bearish and isC1Long and isC2Star and isC3Bullish and isC3Long and isC3GapsUp and isC3ClosesIntoC1
// RSI Confirmation: RSI should be in oversold territory or rising from it
rsiConfirmation = rsiValue <= oversold or (rsiValue[1] <= oversold and rsiValue > rsiValue[1])
// Combined signal
signalMorningStar = isMorningStar and rsiConfirmation
// Plot signals
plotshape(signalMorningStar, title="Morning Star (RSI Confirmed)", location=location.belowbar, color=color.new(color.lime, 0), style=shape.arrowup, size=size.normal)
// Plot RSI in a separate pane
plot(rsiValue, "RSI", color.blue, linewidth=2, display=display.pane)
hline(oversold, "Oversold", color.green)
Optimizing Morning Star Pattern Performance
To maximize the effectiveness of Morning Star patterns in your Pine Script strategies:
- Confirm Downtrend: The Morning Star is a bullish reversal pattern, so it's most reliable when it appears after a clear downtrend. Avoid trading it in an uptrend or sideways market.
- Volume Confirmation: Look for a significant increase in volume, especially on the third bullish candle, as it indicates strong buying interest and adds conviction to the reversal signal.
- Support Levels: Morning Star patterns that form at significant support levels (e.g., previous lows, strong moving averages, Fibonacci retracement levels) tend to be more powerful and reliable.
- Gaps: The presence of gaps (down before the star, up 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 Morning Star Pattern Pitfalls to Avoid
- Ignoring Trend Context: A Morning Star is a reversal pattern; if it appears in an uptrend 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 bearish candle, it indicates a weaker bullish conviction.
- Low Volume Confirmation: A lack of significant volume on the third bullish candle may suggest the reversal is not supported by strong buying interest.
- Over-reliance: Using the Morning Star pattern in isolation without confirmation from other indicators, support/resistance levels, or broader market analysis can lead to false signals.
Conclusion
The Morning Star candlestick pattern is a well-regarded and visually clear signal for bullish reversals. By understanding its precise three-candle formation, its contextual importance within a downtrend, and integrating it with other technical confirmations, you can leverage it effectively in your trading. Implementing Morning 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.