Candlestick patterns are among the oldest and most widely used tools in technical analysis. They visually capture the psychology of buyers and sellers and often provide early warning of potential market reversals. Two of the most popular reversal patterns are the Evening Star (bearish) and the Morning Star (bullish).
In this article, we’ll break down both patterns in detail, explain their trading significance, and then show how to automate the strategy with a clean MQL4 Expert Advisor (EA) that applies modern money management, time filters, and flexible detection parameters.
This EA is designed for backtesting on MetaBacktest.com as well as live/demo testing in MetaTrader 4.
The Patterns Explained
Morning Star (Bullish Reversal)
- Appears at the bottom of a downtrend.
- Signals that selling pressure is exhausted, and buyers may regain control.
Structure:
- Large bearish candle (continuation of downtrend).
- Small candle (bullish, bearish, or doji) — shows indecision.
- Large bullish candle closing well into the body of the first.
This pattern suggests a
shift from bearish sentiment to bullish momentum.
Evening Star (Bearish Reversal)
- Appears at the top of an uptrend.
- Signals that buying momentum is fading, and sellers may take over.
Structure:
- Large bullish candle (continuation of uptrend).
- Small candle (indecision).
- Large bearish candle closing deep into the first candle’s body.
This represents a
shift from bullish sentiment to bearish control.
Implementation notes (design choices):
- For pattern-based targets We used two practical targets common for multi-candle reversal strategies:
- Target1 = midpoint of the first candle's body — conservative, earlier take-profit.
- Target2 = opposite extreme of the first candle (first candle's high for Morning Star / low for Evening Star) — farther target.
- Stop loss (pattern SL) is placed beyond the middle (star) candle's extreme plus
SLBufferPips
.
- If
UseFixedSLTP
is enabled, the EA uses fixed pip SL/TP relative to entry instead of the pattern SL/TP.
- The EA looks for patterns formed in the last
MaxBarsAfterPattern
closed bars (so it doesn't require the pattern to be on the immediately previous bar).
- Lot sizing uses
MODE_TICKVALUE
& MODE_TICKSIZE
to compute pip value per lot; since broker implementations vary, you can use UseFixedLot=true
while testing.
Strategy Rules
- Entry Signals
- Buy (long): when a Morning Star pattern forms.
- Sell (short): when an Evening Star pattern forms.
- Stop Loss
- Placed just beyond the low (for buys) or high (for sells) of the middle candle, with a buffer.
- Optional: use a fixed SL in pips.
- Take Profit
- Target1: midpoint of the first candle’s body (conservative).
- Target2: extreme of the first candle (aggressive).
- Optional: use a fixed TP in pips.
- Filters
- Time filter (only trade within user-defined hours/days).
- Maximum number of open trades allowed.
- Money Management
- Fixed lot size or percentage risk per trade.
- Automatic calculation of lot size based on stop-loss distance.
Why Automate This Strategy?
While identifying these patterns visually is easy, trading them consistently and with proper risk management is not. By coding the strategy into an Expert Advisor (EA), traders gain:
- Consistency — no missed setups or emotional hesitation.
- Backtestability — run historical tests on MetaBacktest.com to measure performance.
- Risk control — automated money management and exit rules.
- Efficiency — the EA can scan multiple pairs and timeframes without effort.
This EA solves all of that:
- No emotions.
- Simple yet effective price action strategy.
- Precise execution.
- Strict money management.
- Optimizable for different pairs and sessions.
- Adjustable tolerances let users fine-tune pattern recognition for different markets.
Limitations & Next Steps
No trading system is perfect. Here are some things to consider:
- Star patterns can fail in strong trending markets (trend continuation overwhelms reversal).
- Adding filters (RSI, MACD, moving averages) can improve win rate.
- Future upgrades could include partial exits (Target1 + Target2 scaling out).
Backtest Results by MetaBacktest
We ran multiple backtests of the
MQL4 Expert Advisor using
MetaBacktest to ensure fair and transparent results.
Test Parameters:
- Instrument : EURUSD
- Timeframe : H4
- Period : Jan 2012 – Aug 2025
- Default Inputs
* You can download the EA file from the
Download Box HERE
Process time: 0:02:42.172
Key Results:
Test Parameters:
- Instrument : EURUSD
- Timeframe : H4
- Period : Jan 2012 – Aug 2025
- Default Inputs, Except:
- MaxBarsAfterPattern : 18
- FirstBodyMinPips : 18
- ThirdBodyMinPips: 18
- MiddleBodyMaxPips: 14
- RiskPercent: 0.2
- PrimaryTargetSelect: 1
- MaxTotalTrades: 22
* You can download the setting file from the
Download Box HERE
Process time: 0:02:52.140
Key Results:
Comparison by MetaBacktest:
Final Thoughts
The
Morning Star and
Evening Star are timeless candlestick reversal patterns, and with the help of an EA, traders can apply them consistently and with discipline.
By automating the strategy, we combine classical technical analysis with modern systematic trading. With proper backtesting on
MetaBacktest.com, traders can evaluate performance across pairs, timeframes, and market conditions before deploying it in live trading.
Morning-and-Evening-Stars_MetaBacktest.ex4
Morning-and-Evening-Stars_MetaBacktest.mq4
EURUSD-H4-set1.set
Report-EURUSD-H4.zip
Report-EURUSD-H4-Set1.zip
Please Login or Signup
to be able to download the files.
This article does a nice job bridging classic candlestick theory with quant-style testing. Respect to whoever wrote it
I didn’t expect such detailed breakdowns on entry and exit logic.
I also liked that they didn’t cherry-pick a perfect chart
I ran a quick backtest... pushing SL a bit further did increase win rate slightly, but the drawdowns got worse. Worth exploring with your risk tolerance.