CDL_MORNINGDOJISTAR (Morning Doji Star)¶
Overview¶
The Morning Doji Star is a three-candle bullish reversal pattern that typically appears at the bottom of a downtrend. It consists of a long bearish candle, followed by a doji that gaps down, and then a long bullish candle that closes well into the body of the first candle. This pattern signals potential trend exhaustion and a shift from bearish to bullish sentiment.
Parameters¶
| Parameter | Type | Default | Description |
|---|---|---|---|
open |
Array |
Required | Array of opening prices for each period |
high |
Array |
Required | Array of high prices for each period |
low |
Array |
Required | Array of low prices for each period |
close |
Array |
Required | Array of closing prices for each period |
penetration |
Float | 0.3 | Percentage of penetration of the third candle into the first candle's body (0.0 to 1.0) |
Parameter Details¶
Note: Array elements should be ordered from oldest to newest (chronological order)
open - Opening price for each trading period - Must be same length as high, low, and close arrays - Used to determine candle body direction and size
high - Highest price reached during each trading period - Must be same length as other price arrays - Used to identify gaps and shadow lengths
low - Lowest price reached during each trading period - Must be same length as other price arrays - Critical for identifying doji characteristics and gaps
close - Closing price for each trading period - Must be same length as other price arrays - Used to determine candle body direction and completion of pattern
penetration - Controls how far the third candle must close into the first candle's body - Default 0.3 means 30% penetration required - Higher values (e.g., 0.5) make pattern detection more strict - Lower values (e.g., 0.1) make pattern detection more lenient
Usage¶
Basic Usage¶
require 'sqa/tai'
# Price data arrays
open = [50.0, 48.0, 47.0, 47.5, 49.0]
high = [50.5, 48.2, 47.2, 47.6, 50.0]
low = [48.0, 46.5, 46.8, 47.3, 47.4]
close = [48.0, 47.0, 47.0, 47.4, 49.5]
result = SQA::TAI.cdl_morningdojistar(open, high, low, close)
puts "Pattern Signal: #{result.last}"
With Custom Penetration¶
# More strict pattern detection with 50% penetration
result = SQA::TAI.cdl_morningdojistar(
open,
high,
low,
close,
penetration: 0.5
)
# Check for pattern detection
if result.last == 100
puts "Bullish Morning Doji Star detected!"
end
Real-Time Pattern Monitoring¶
# Monitor multiple periods for pattern emergence
open = [52.0, 50.0, 48.0, 47.0, 47.5, 49.0, 50.5]
high = [52.5, 50.5, 48.2, 47.2, 47.6, 50.0, 51.0]
low = [50.0, 48.0, 46.5, 46.8, 47.3, 47.4, 49.5]
close = [50.0, 48.0, 47.0, 47.0, 47.4, 49.5, 50.8]
result = SQA::TAI.cdl_morningdojistar(open, high, low, close)
result.each_with_index do |signal, index|
if signal == 100
puts "Bullish pattern detected at period #{index}"
puts "Entry: #{close[index]}, Previous low: #{low[index-1]}"
end
end
Understanding the Indicator¶
What It Measures¶
The Morning Doji Star pattern measures potential reversal points at the end of bearish trends. It identifies a specific three-candle sequence that suggests sellers are losing control and buyers may be entering the market. The pattern is valuable because:
- It shows indecision (doji) after a strong bearish move, indicating seller exhaustion
- The gap down followed by a gap up demonstrates a dramatic shift in sentiment
- The strong bullish third candle confirms buyer commitment
- It provides an early warning of potential trend reversal before other indicators
Pattern Formation¶
The pattern requires three consecutive candles in this specific sequence:
-
First Candle (Bearish): A long bearish candle showing strong selling pressure, typically at the end of a downtrend. The candle should have a substantial body with close significantly below open.
-
Second Candle (Doji): A doji candle that gaps down from the first candle's close. The doji indicates market indecision with opening and closing prices nearly equal. This shows sellers are losing momentum.
-
Third Candle (Bullish): A long bullish candle that gaps up from the doji and closes well into the first candle's body (controlled by the penetration parameter). This confirms buyers have taken control.
Key Characteristics: - The doji must gap away from both the first and third candles - The third candle should close at least 30% (default) into the first candle's body - The gaps demonstrate dramatic sentiment shifts - All three candles should show clear directional intent or indecision
Indicator Characteristics¶
- Range: Returns integer values: 0 (no pattern), +100 (bullish pattern detected)
- Type: Pattern recognition, reversal indicator
- Lag: None - identifies patterns as they complete (requires three candles)
- Best Used: At the end of established downtrends, oversold conditions
- Reliability: Moderate to high when confirmed with other indicators
- Time Frame: Works on all time frames; more reliable on daily and weekly charts
Interpretation¶
Signal Values¶
The indicator returns specific integer values:
- +100 (Bullish Signal): Morning Doji Star pattern detected
- Indicates potential bullish reversal
- Suggests downtrend may be ending
- Buyers are overwhelming sellers
-
Consider long positions with confirmation
-
0 (No Pattern): No Morning Doji Star pattern at this position
- Pattern requirements not met
- Continue monitoring other indicators
- Wait for pattern completion or other signals
Pattern Strength Indicators¶
Assess the reliability of the pattern by examining:
- Prior Trend Strength
- Pattern is most reliable after extended downtrends
- Multiple bearish candles before pattern increases significance
-
Weaker after sideways or choppy price action
-
Doji Quality
- Smaller doji body indicates stronger indecision
- Long shadows on doji show battle between buyers and sellers
-
Doji at support level increases pattern reliability
-
Third Candle Penetration
- Deeper penetration into first candle = stronger reversal signal
- Close above first candle's midpoint is particularly bullish
-
Higher volume on third candle confirms conviction
-
Gap Sizes
- Larger gaps indicate more dramatic sentiment shift
- Visible gaps on charts are more psychologically significant
- Gap up on third candle especially important
Context Considerations¶
- Location: Most effective at established support levels or after capitulation
- Volume: Increasing volume on third candle confirms reversal strength
- Market Condition: Works best in trending markets, less reliable in ranging markets
- Time Frame: Higher time frames (daily, weekly) provide more reliable signals
Trading Signals¶
Buy Signals¶
Primary conditions for entering long positions:
- Pattern Confirmation
- All three candles meet Morning Doji Star criteria
- Signal value = +100
-
Doji clearly gaps from both first and third candles
-
Entry Criteria
- Enter on close of third candle or
- Wait for confirmation: enter on break above third candle's high
-
More conservative: wait for next candle to close higher
-
Additional Confirmation Factors
- Pattern forms at known support level
- RSI or other oscillators show oversold conditions
- Volume increases on third candle
- Prior downtrend was extended and clear
Example Scenario:
# After extended downtrend, pattern detected at support
if result.last == 100 &&
rsi.last < 30 && # Oversold
close.last > support_level && # Above support
volume.last > volume[-2] # Increasing volume
entry_price = close.last
stop_loss = low[-2] - (atr.last * 1.5) # Below doji low
target = entry_price + ((entry_price - stop_loss) * 2) # 2:1 reward/risk
puts "BUY Signal: Enter at #{entry_price}"
puts "Stop Loss: #{stop_loss}"
puts "Target: #{target}"
end
Position Management¶
Stop Loss Placement: - Conservative: Below the low of the doji (second candle) - Aggressive: Below the low of the third candle - ATR-based: 1.5-2x ATR below entry point
Take Profit Targets: - First target: Recent resistance level or 1:1 reward/risk - Second target: Next major resistance or 2:1 reward/risk - Trailing stop: After first target hit, trail with 2x ATR
Position Sizing: - Risk 1-2% of capital per trade - Calculate position size based on stop loss distance - Reduce size if pattern appears in choppy/ranging market
Exit Signals¶
Conditions for closing long positions:
- Stop Loss Triggers
- Price closes below stop loss level
- Subsequent bearish engulfing pattern forms
-
Break below doji's low with volume
-
Take Profit Conditions
- Price reaches predetermined target levels
- Strong resistance level reached
-
Bearish reversal pattern forms at resistance
-
Pattern Failure Signs
- Fourth candle closes below third candle with high volume
- Price fails to move higher after pattern
- Bearish candlestick pattern forms immediately after
Best Practices¶
Optimal Use Cases¶
The Morning Doji Star works best in these conditions:
Market Conditions: - Clear downtrend preceding the pattern (at least 5-10 bearish candles) - Oversold conditions per momentum indicators - Market approaching major support levels - Low volatility on doji, increasing volatility on third candle
Time Frames: - Daily charts: Most reliable and widely recognized - Weekly charts: Stronger signals, fewer occurrences - 4-hour charts: Good for swing trading - Intraday (< 1 hour): Less reliable, more false signals
Asset Classes: - Stocks: Highly effective, especially large-cap stocks - Forex: Works well on major pairs with sufficient liquidity - Commodities: Reliable on liquid contracts - Cryptocurrencies: Can work but volatility creates false signals
Combining with Other Indicators¶
Enhance reliability by confirming with complementary indicators:
With Trend Indicators: - Moving Averages: Pattern near 200-day MA support increases reliability - MACD: Bullish divergence or histogram turning positive confirms reversal - ADX: Low ADX suggests trend change possible; pattern helps identify direction
With Momentum Indicators: - RSI: Pattern + RSI < 30 = high probability reversal - Stochastic: Oversold stochastic crossing up confirms pattern - CCI: Emerging from oversold territory strengthens signal
With Volume Indicators: - Volume: Third candle volume > average confirms conviction - OBV: Rising OBV confirms accumulation despite falling prices - Volume Profile: Pattern at high volume support node more significant
With Support/Resistance: - Fibonacci Retracements: Pattern at 50% or 61.8% level highly significant - Pivot Points: Pattern at daily/weekly pivot support adds conviction - Horizontal Support: Historical support level validates reversal potential
Common Pitfalls¶
Avoid these mistakes when trading Morning Doji Star patterns:
- Ignoring Prior Trend
- Pattern requires established downtrend to be valid
- Appearing in uptrend or sideways market reduces reliability
-
Always confirm preceding bearish trend over multiple periods
-
Trading Without Confirmation
- Don't enter on second candle expecting doji
- Wait for third candle completion
-
Consider waiting for fourth candle to confirm reversal
-
Poor Risk Management
- Pattern can fail; always use stop losses
- Don't risk more than 2% of capital on single trade
-
Account for gap risk, especially in volatile markets
-
Neglecting Volume Analysis
- Low volume on third candle suggests weak conviction
- Declining volume through pattern reduces reliability
-
Always check volume confirms price action
-
Time Frame Mismatch
- Using pattern on 5-minute chart with daily trend analysis
- Ensure time frame of pattern matches trading style
-
Higher time frames provide more reliable signals
-
Over-optimization of Penetration Parameter
- Don't adjust penetration based on historical data mining
- Stick to default 0.3 or adjust slightly based on asset volatility
- Over-optimization leads to curve fitting and poor future performance
Parameter Selection Guidelines¶
Choose optimal parameters based on trading style:
Short-term Trading (Day Trading): - Use 5-15 minute charts cautiously - Penetration: 0.4-0.5 (more strict) to reduce false signals - Require additional confirmation (volume, momentum) - Tighter stops due to noise in intraday data
Medium-term Trading (Swing Trading): - Use 4-hour to daily charts (recommended) - Penetration: 0.3 (default) works well - Balance between sensitivity and reliability - Hold positions for multiple days to weeks
Long-term Trading (Position Trading): - Use daily to weekly charts - Penetration: 0.2-0.3 (slightly looser) to catch all major reversals - Fewer signals but higher reliability - Combine with fundamental analysis
Backtesting Guidelines: - Test default parameters first (penetration = 0.3) - Vary penetration from 0.2 to 0.5 in 0.1 increments - Evaluate win rate, profit factor, and drawdown - Choose parameters that work across multiple assets - Avoid parameters that work for only one specific period
Practical Example¶
Complete trading scenario with context:
require 'sqa/tai'
# Historical price data showing downtrend
open = [55.0, 54.0, 53.0, 51.5, 50.0, 48.5, 47.0, 47.5, 49.0, 50.5, 51.0]
high = [55.5, 54.5, 53.5, 52.0, 50.5, 49.0, 47.2, 47.6, 50.0, 51.0, 51.5]
low = [54.0, 53.0, 51.5, 50.0, 48.5, 47.0, 46.8, 47.3, 47.4, 49.5, 50.5]
close = [54.0, 53.0, 51.5, 50.0, 48.5, 47.0, 47.0, 47.4, 49.5, 50.8, 51.2]
# Calculate pattern with default penetration
pattern = SQA::TAI.cdl_morningdojistar(open, high, low, close)
# Calculate supporting indicators
rsi = SQA::TAI.rsi(close, time_period: 14)
sma_50 = SQA::TAI.sma(close, time_period: 50)
# Analyze most recent signal
current_signal = pattern.last
previous_signals = pattern[-4..-2]
if current_signal == 100
puts "=" * 50
puts "MORNING DOJI STAR PATTERN DETECTED"
puts "=" * 50
# Pattern details
puts "\nPattern Structure:"
puts " First Candle (Bearish): Open #{open[-3]}, Close #{close[-3]}"
puts " Doji Candle: Open #{open[-2]}, Close #{close[-2]}"
puts " Third Candle (Bullish): Open #{open[-1]}, Close #{close[-1]}"
# Calculate pattern metrics
first_body = (open[-3] - close[-3]).abs
doji_body = (open[-2] - close[-2]).abs
third_body = (close[-1] - open[-1]).abs
penetration_pct = (close[-1] - close[-3]) / first_body
puts "\nPattern Metrics:"
puts " First candle body: #{first_body.round(2)}"
puts " Doji body: #{doji_body.round(2)}"
puts " Third candle body: #{third_body.round(2)}"
puts " Penetration: #{(penetration_pct * 100).round(1)}%"
# Confirmation factors
puts "\nConfirmation Analysis:"
puts " Current RSI: #{rsi.last.round(2)}"
puts " RSI Status: #{rsi.last < 30 ? 'OVERSOLD ✓' : 'Not oversold'}"
puts " 50-day SMA: #{sma_50.last.round(2)}"
puts " Price vs SMA: #{close.last < sma_50.last ? 'Below (reversal setup) ✓' : 'Above'}"
# Trend confirmation
downtrend_confirmed = close[-6..-4].all? { |c| c > close[-3] }
puts " Prior downtrend: #{downtrend_confirmed ? 'Confirmed ✓' : 'Weak'}"
# Trading decision
puts "\nTrading Decision:"
if rsi.last < 35 && close.last < sma_50.last && downtrend_confirmed
# Calculate position parameters
entry = close.last
stop_loss = low[-2] * 0.98 # 2% below doji low
risk_amount = entry - stop_loss
target_1 = entry + (risk_amount * 1.5) # 1.5:1 R/R
target_2 = entry + (risk_amount * 3.0) # 3:1 R/R
puts " STRONG BUY SIGNAL - Multiple confirmations"
puts "\nTrade Setup:"
puts " Entry Price: $#{entry.round(2)}"
puts " Stop Loss: $#{stop_loss.round(2)} (Risk: $#{risk_amount.round(2)})"
puts " Target 1 (50% position): $#{target_1.round(2)}"
puts " Target 2 (50% position): $#{target_2.round(2)}"
puts " Risk/Reward: 1:1.5 and 1:3"
# Position sizing example (for $10,000 account, 2% risk)
account_size = 10000
risk_per_trade = account_size * 0.02
position_size = (risk_per_trade / risk_amount).to_i
puts "\nPosition Sizing (2% risk on $#{account_size} account):"
puts " Shares to buy: #{position_size}"
puts " Total position value: $#{(position_size * entry).round(2)}"
puts " Maximum risk: $#{risk_per_trade.round(2)}"
elsif rsi.last < 40
puts " MODERATE BUY SIGNAL - Consider smaller position"
puts " Suggestion: Wait for additional confirmation or enter with 50% position"
else
puts " WEAK SIGNAL - Pattern present but confirmations lacking"
puts " Suggestion: Monitor for additional confirmation before entry"
end
elsif pattern[-2] == 100
puts "Pattern detected in previous period - Monitor position"
puts "Current price: #{close.last}"
puts "Entry was: #{close[-2]}"
puts "Profit/Loss: #{((close.last - close[-2]) / close[-2] * 100).round(2)}%"
else
# No pattern - continue monitoring
if close.last < close[-1] && close[-1] < close[-2]
puts "Downtrend continuing - Watch for Morning Doji Star formation"
puts "Current price: #{close.last}"
puts "RSI: #{rsi.last.round(2)}"
end
end
Related Indicators¶
Similar Patterns¶
-
Morning Star: Similar three-candle bullish reversal pattern but with a small real body instead of doji on second candle. Morning Doji Star is generally considered slightly more reliable due to the doji showing stronger indecision.
-
Abandoned Baby: More rare and reliable version with gaps on both sides of the doji. Requires complete gap isolation of middle candle, making it stronger but less frequent.
-
Piercing Pattern: Two-candle bullish reversal pattern. Simpler than Morning Doji Star but may provide earlier signals with potentially lower reliability.
Complementary Patterns¶
-
Bullish Engulfing: Can follow Morning Doji Star to provide additional confirmation of reversal. The combination of both patterns significantly increases probability of successful reversal.
-
Hammer: Single candle pattern that can appear as the third candle in Morning Doji Star. Recognizing hammer characteristics strengthens the overall signal.
-
Evening Doji Star: The bearish counterpart to Morning Doji Star, appearing at tops. Understanding both patterns provides complete reversal recognition capability.
Pattern Family¶
The Morning Doji Star belongs to the Star Pattern Family:
- Morning Star: Uses small real body instead of doji
- Morning Doji Star: Features doji for stronger indecision signal
- Evening Star: Bearish reversal at tops
- Evening Doji Star: Bearish reversal with doji
Evolutionary Relationship: The Morning Doji Star is considered an evolution of the Morning Star pattern, with the doji providing a more specific indication of market indecision. Japanese candlestick analysis traditionally views the doji as a more significant reversal indicator than a small real body.
When to prefer Morning Doji Star: - When seeking higher probability (though less frequent) reversal signals - In markets where doji patterns have proven historically reliable - When risk management requires high-confidence entry signals
When to use Morning Star instead: - For more frequent trading opportunities - In less liquid markets where true dojis rarely form - When backtesting shows Morning Star provides better results for specific asset
Advanced Topics¶
Multi-Timeframe Analysis¶
Enhance pattern reliability using multiple timeframes:
Primary Timeframe Strategy: 1. Identify Morning Doji Star on daily chart (primary trading timeframe) 2. Confirm weekly chart shows downtrend and oversold conditions 3. Use 4-hour chart for precise entry timing after pattern completion 4. Monitor 1-hour chart for early exit signals if pattern fails
Timeframe Confluence: - Pattern on daily + weekly chart = very high probability signal - Pattern on daily, waiting for 4-hour confirmation = reduced risk entry - Pattern on 4-hour aligned with daily support = good swing trade setup
Example Multi-Timeframe Approach:
# Check daily for pattern
daily_pattern = SQA::TAI.cdl_morningdojistar(daily_open, daily_high, daily_low, daily_close)
# Confirm weekly trend
weekly_sma = SQA::TAI.sma(weekly_close, time_period: 20)
weekly_downtrend = weekly_close.last < weekly_sma.last
# Entry on 4-hour confirmation
if daily_pattern.last == 100 && weekly_downtrend
# Monitor 4-hour chart for entry trigger
four_hour_pattern = SQA::TAI.cdl_morningdojistar(h4_open, h4_high, h4_low, h4_close)
# Enter when 4-hour also shows pattern or bullish confirmation
end
Market Regime Adaptation¶
Pattern behavior varies by market condition:
Trending Markets (ADX > 25): - Pattern most reliable after strong trends - Higher success rate in established downtrends - Use standard penetration (0.3) and standard confirmation
Ranging Markets (ADX < 20): - Pattern less reliable, many false signals - Increase penetration to 0.4-0.5 for stricter detection - Require additional confirmation from oscillators - Consider reducing position size
High Volatility (ATR increasing): - Gaps more common, patterns form more frequently - May need wider stops to avoid premature exit - Pattern completion may span more time - Confirm with volume to separate noise from signal
Low Volatility (ATR decreasing): - True gaps less likely, doji may be weak - Pattern may signal imminent volatility expansion - Earlier entry can capture larger moves - Tighter stops appropriate
Statistical Validation¶
Understanding pattern reliability through statistical analysis:
Historical Success Rates: - Academic studies show 60-65% success rate in trending markets - Success rate drops to 45-50% in ranging markets - Daily timeframe shows better results than intraday - Confirmation with RSI < 30 increases success to 70-75%
Backtesting Considerations:
# Example backtesting framework
def backtest_morning_doji_star(price_data, start_date, end_date)
trades = []
price_data.each_with_index do |data, i|
next if i < 3 # Need at least 3 candles
pattern = SQA::TAI.cdl_morningdojistar(
data[:open], data[:high], data[:low], data[:close]
)
if pattern[i] == 100
entry = data[:close][i]
stop = data[:low][i-1] * 0.98
target = entry + ((entry - stop) * 2)
# Track trade through subsequent data
trades << {
entry: entry,
stop: stop,
target: target,
date: data[:date][i]
}
end
end
# Analyze results
analyze_trades(trades)
end
Key Metrics to Track: - Win rate (% of profitable trades) - Average win vs average loss - Profit factor (gross profit / gross loss) - Maximum drawdown - Sharpe ratio - Pattern frequency vs opportunity cost
Optimization Tips: - Test across multiple assets and market conditions - Avoid over-fitting to specific time periods - Include transaction costs in calculations - Account for slippage, especially on gaps - Consider different penetration parameters systematically
References¶
-
"Japanese Candlestick Charting Techniques" by Steve Nison: The definitive Western text on candlestick patterns, includes detailed coverage of Morning Doji Star pattern with historical context and trading applications.
-
"Technical Analysis of the Financial Markets" by John Murphy: Comprehensive technical analysis reference with section on candlestick patterns and their integration with Western technical analysis.
-
"Encyclopedia of Candlestick Charts" by Thomas Bulkowski: Statistical analysis of candlestick pattern performance, including success rates and failure rates for Morning Doji Star in various market conditions.
-
Original Japanese Candlestick Research: Pattern originated in 18th century Japanese rice trading, documented in various historical texts on Sakata's Five Methods.
-
Online Resources:
- StockCharts.com Candlestick Pattern Reference
- Investopedia Technical Analysis Guide
- TradingView Pattern Recognition Tools