Disclaimer: This article is for educational and informational purposes only. It does not constitute financial or investment advice. Trading forex and CFDs carries significant risk of loss. Past performance of any strategy — including backtests — does not guarantee future results. Never trade with money you cannot afford to lose.
What Is This Strategy?
The Twin Close Sandwich Reversal is a pure price-action reversal strategy built on the classic Stick Sandwich candlestick pattern, and it is designed for traders who want to study reversals without relying on lagging indicators. Rather than reading a moving average, an oscillator, or a momentum line, this strategy reads the raw relationship between three consecutive candles. The "twin close" refers to the pattern's defining feature: two same-colour candles that close at virtually the same price, with an opposite-colour candle wedged between them like the filling in a sandwich.
That shared closing level is the heart of the idea. In technical analysis, a price level that the market visits twice and refuses to break through is treated as a form of support (a floor) or resistance (a ceiling). When two candles close at the same spot at the bottom of a decline, the strategy interprets it as a twice-defended floor — a shelf the sellers could not push below. When two candles close at the same spot at the top of a rally, it reads as a twice-tested ceiling. The middle candle, which moves sharply in the opposite direction before price snaps back to the shelf, adds context that the level was genuinely challenged and held.
This EA is best suited as a learning tool for traders who want to understand structural, price-derived reversals: how candlestick patterns are formalised into rules, how swing highs and lows define risk, and how stops and targets can be anchored to market structure instead of arbitrary pip counts. It is a mean-reversion / counter-trend concept, so it naturally appeals to those studying how markets turn rather than how they trend. It is not a "set and forget" money machine — it is a transparent, rules-based framework for examining a well-known pattern.
How It Works
The strategy evaluates only closed candles and acts once per newly formed bar. It inspects the three most recently closed bars — labelled A (oldest), B (middle), and C (newest) — and measures everything against the recent average bar range (the average High-minus-Low over a configurable period). Using average range keeps every threshold adaptive: the same rules behave sensibly whether volatility is high or low.
The strategy signals a long (bullish sandwich) when:
- Bar A is bearish (closes below its open) and Bar C is also bearish — the two "bread" candles.
- Bar B, the filling, is bullish (closes above its open) and closes meaningfully above the shelf — its rise must exceed the
MinMiddlePctfraction of average range. - Bars A and C close at almost exactly the same price — their difference must fall within the
CloseTolerancePcttolerance band. This is the "twin close" that forms the floor. - The shared low of the three-bar trio is a fresh swing low, meaning no bar within the lookback window dipped lower. This confirms the shelf sits at the bottom of a decline, not in the middle of a range.
The strategy signals a short (bearish sandwich) using the exact mirror logic: two bullish "bread" candles closing at the same level, a bearish filling candle that drops meaningfully below the shelf, matched closes within tolerance, and the trio's high registering as a fresh swing high.
Entry, stop-loss, and take-profit logic:
- On a bullish signal, the strategy enters a buy at the current Ask; on a bearish signal, it sells at the current Bid.
- The stop-loss is structural, placed just beyond the sandwich's outer extreme — below the trio's lowest low for longs, above the trio's highest high for shorts — with an extra cushion set by
StopBufferPct. Because the stop is derived from price structure, the risk it defines reflects the actual pattern rather than a fixed distance. - The take-profit is a multiple of that measured risk, controlled by
RewardRisk. With the default reward:risk of 2.0, the target sits twice as far from entry as the stop. - Only one position at a time is held per symbol (tracked by the strategy's magic number). Once a trade is open, the stop-loss and take-profit manage the exit entirely — there is no separate trailing or time-based close.
Because no indicators are used, every threshold — tolerance, middle-bar excursion, and stop buffer — scales off the same recent average range, keeping the logic self-contained and price-driven.

Strategy Parameters
| Parameter | Default | Min | Max | Description |
|---|---|---|---|---|
| LookbackBars | 20 | 5 | 60 | Number of prior bars checked to confirm the sandwich's low/high is a fresh swing extreme. Larger values demand a more significant swing point. |
| CloseTolerancePct | 12.0 | 2.0 | 40.0 | How closely the two matched closes must align, as a percentage of average bar range. Lower values require a tighter "twin close." |
| MinMiddlePct | 45.0 | 10.0 | 150.0 | Minimum distance the middle (opposite-colour) candle must travel off the shelf, as a percentage of average range. Filters out shallow, unconvincing fillings. |
| StopBufferPct | 25.0 | 0.0 | 100.0 | Extra cushion added beyond the trio's outer extreme when placing the stop-loss, as a percentage of average range. |
| RewardRisk | 2.0 | 0.5 | 5.0 | Reward-to-risk multiple. Sets the take-profit distance as a multiple of the measured stop distance. |
| RangePeriod | 14 | 5 | 30 | Number of bars used to compute the average bar range that scales all thresholds. |
| Lots | 0.10 | 0.01 | 1.0 | Fixed trade volume in lots per position. |

Recommended Chart Settings
This strategy was designed around candlestick structure, so it works best on timeframes where each candle carries meaningful information — commonly the H1 (1-hour) or H4 (4-hour) charts on major forex pairs such as EUR/USD or GBP/USD, where spreads are tight and price action is relatively clean. Higher timeframes tend to produce fewer but more structurally significant sandwich patterns, which suits a reversal concept.
You are encouraged to experiment on a demo account across several symbols and timeframes. Reversal patterns behave very differently in trending versus ranging markets, and results will vary considerably depending on the instrument, session, and prevailing volatility. There is no single "correct" setting — the defaults are a reasonable starting point for study, not a guaranteed configuration.
How to Install on MetaTrader 5
- Download the .ex5 file from the link below.
- Copy it to your MT5
MQL5\Expertsfolder. - Restart MetaTrader 5 or refresh the Navigator panel.
- Drag the EA onto a chart matching the recommended symbol and timeframe.
- Configure the input parameters and enable Algo Trading.
What to Consider Before Using This EA
Strengths. The Twin Close Sandwich Reversal is refreshingly transparent. Because it uses no indicators, there is nothing to lag or repaint — every decision traces directly to closed-candle prices you can verify on the chart by eye. The stop-loss is anchored to real structure (the pattern's outer extreme), and the swing-low / swing-high filter helps ensure signals appear at meaningful turning points rather than in the middle of noise. The adaptive, range-based thresholds mean the same rules travel reasonably well between calm and volatile conditions.
Limitations. The Stick Sandwich is a comparatively rare pattern, and the extra filters here — fresh swing extreme, minimum middle-bar excursion, tight twin-close tolerance — make qualifying setups rarer still. That means long stretches with no trades, which requires patience and makes robust evaluation slow. As a counter-trend approach, it is vulnerable to strong, persistent trends: a "floor" can look perfect right up until the market slices straight through it. Candlestick reversal patterns also carry a well-documented weakness — they signal a potential turn, not a confirmed one, and many patterns fail. Finally, the fixed lot size does not scale risk to account equity, and a single position at a time means the EA will sit out other opportunities while a trade is live.
Where it may underperform. Choppy, low-volatility ranges can generate matched closes that are noise rather than genuine support/resistance, and powerful trending phases can repeatedly stop out counter-trend entries. Treat this EA as a lens for studying how a classic pattern is codified — not as a standalone edge.
Risk Management Tips
Regardless of the strategy, disciplined risk management is what keeps a trading account alive long enough to learn. Consider the following general principles:
- Position sizing: Rather than trading a fixed lot blindly, size each position so that hitting the stop-loss costs only a small, predefined fraction of your account. Many educators suggest risking no more than 1–2% of account equity per trade.
- Test on a demo account first: Run the EA on a demo or simulator for an extended period before considering any live capital. This lets you observe how often it trades and how it behaves in different market conditions at no financial risk to you.
- Understand drawdown: Even a sound strategy experiences losing streaks. Study the maximum peak-to-trough decline you could reasonably face, and ask whether you could tolerate it emotionally and financially.
- Never over-leverage: Leverage magnifies losses as much as gains. Keep total exposure conservative, especially when trading a counter-trend concept.
- Keep a trading journal: Record why each trade triggered and how it resolved. Over time this teaches you more about the pattern than any single backtest.
The goal of using an EA like this is education — understanding market structure, candlestick logic, and risk — not chasing a shortcut.
Risk Warning
Trading foreign exchange, CFDs, and other leveraged financial instruments involves substantial risk of loss and is not suitable for all investors. The strategies and tools discussed on this page are provided for educational purposes only and do not constitute financial advice, investment recommendations, or solicitation to trade. Always consult a qualified financial adviser before making trading decisions. Past backtest performance is not indicative of future results.
Downloads
- Expert Advisor: TwinCloseSandwichReversal.ex5 (27 downloads)
- Source Code: TwinCloseSandwichReversal.mq5 (32 downloads)
- Documentation: TwinCloseSandwichReversal.pdf (29 downloads)