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 Doji Extreme Reversal is a counter-trend, price-action expert advisor (EA) for MetaTrader 5 built around the doji candlestick — a candle whose open and close finish almost in the same place, producing little or no real "body." A doji is the market's clearest fingerprint of indecision: buyers and sellers fought to a draw for that bar. On its own a doji means very little, which is the key idea this strategy is designed to teach. Its meaning comes almost entirely from where it appears on the chart, not from the candle itself.
This EA looks for a doji that forms at a swing extreme — the highest high or lowest low of a recent window of candles — and then waits for the next candle to confirm a reversal before acting. In plain terms, a doji at the top of a recent up-push may indicate that buyers have run out of fuel exactly where they were strongest; a doji at the bottom of a down-push may indicate sellers stalled at the lows. The strategy never anticipates; it waits for the market to resolve the indecision and then trades that resolution. It also borrows the Average True Range (ATR) — a standard measure of recent volatility — but only as a filter and a stop-loss buffer, never to generate the signal itself.
As a learning tool, the Doji Extreme Reversal is well suited to traders who want to study exhaustion and mean-reversion behaviour: how markets behave at the edges of a move rather than in the middle of a trend. Because it is a counter-trend approach, it is best treated as an educational study in price-action geometry and confirmation logic — not as a "set and forget" system. Understanding why it enters, and just as importantly why it stays out, is the real value here.
How It Works
The strategy evaluates candles only once per freshly-closed bar, so it never reacts to a half-formed candle. It labels three candles: D (the doji candidate, two bars back), C (the confirmation candle that just closed, one bar back), and the window of bars that came before D. Here is what the strategy checks, step by step:
- Indecision test (the doji): The candle D must have a tiny body relative to its full range — specifically
|close − open| ≤ DojiBodyRatio × (high − low). This is what mathematically defines a doji here. - Meaningful size filter: D's full range (high minus low) must be at least
MinRangeAtr × ATR. This rejects "micro-dojis" that are too small to carry information. - Location test (the swing extreme): D's high must be the highest high of the preceding
SwingLookbackbars (a swing top), or D's low must be the lowest low of that window (a swing bottom). If the doji is not at an extreme, there is no setup. - Confirmation close (the resolution):
- For a short setup, the confirmation candle C must be bearish (it closes below its open) and close below D's low — price has rejected the highs.
- For a long setup, C must be bullish (it closes above its open) and close above D's high — price has rejected the lows.
When all conditions line up, the strategy signals a trade in the direction of the rejection:
- Stop-loss logic: On a short, the stop is placed just beyond the doji's high at
D.high + AtrBuffer × ATR. On a long, it sits just beyond the doji's low atD.low − AtrBuffer × ATR. The ATR buffer gives the structural stop a little breathing room based on current volatility. - Take-profit logic: The distance from entry to stop is the "risk." The target is placed at
RiskReward × riskin the trade's direction. With the default reward-to-risk of 2.0, the take-profit is twice the stop distance away from entry. - One position at a time: The EA holds only a single open position per symbol for its magic number, so it will not stack trades on the same signal.
Framed simply: the strategy signals a reversal when a meaningful doji prints at a recent extreme and the very next candle closes back through it. It is a confirmation-based, wait-and-see approach rather than a predictive one.

Strategy Parameters
| Parameter | Default | Min | Max | Description |
|---|---|---|---|---|
| Lots | 0.10 | 0.01 | 1.00 | Order volume in lots. Controls position size; lower values reduce per-trade exposure. |
| SwingLookback | 10 | 4 | 40 | Number of bars before the doji used to define a swing high or low. Larger values demand a more significant extreme. |
| DojiBodyRatio | 0.12 | 0.05 | 0.35 | Maximum body-to-range ratio for a candle to qualify as a doji. Smaller values require a "purer," more balanced doji. |
| AtrPeriod | 14 | 5 | 30 | Lookback period for the ATR volatility filter and stop buffer. |
| AtrBuffer | 0.25 | 0.00 | 1.50 | ATR multiple added beyond the structural stop, giving the stop-loss extra room. |
| RiskReward | 2.0 | 1.0 | 5.0 | Reward-to-risk ratio. The take-profit distance is this multiple of the stop distance. |
| MinRangeAtr | 0.50 | 0.00 | 2.00 | Minimum doji range as an ATR multiple. Filters out dojis too small to be meaningful. |

Recommended Chart Settings
The Doji Extreme Reversal was designed with XAU/USD (gold) or EUR/USD on the M15 (15-minute) timeframe in mind, though the logic is symbol- and timeframe-agnostic and can be studied on any liquid instrument. M15 offers a reasonable balance between signal frequency and noise for a pattern that depends on clean swing extremes. Keep in mind that results will vary considerably across different symbols, brokers, spreads, and market conditions — a setting that behaves one way during a calm range may behave very differently during high-volatility news periods. Always test on the exact symbol and timeframe you intend to study before drawing any conclusions.
How to Install on MetaTrader 5
- Download the
DojiExtremeReversal.ex5file 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
Like every approach, the Doji Extreme Reversal has clear strengths and clear limitations, and an honest understanding of both is essential.
Strengths. The logic is transparent and purely price-action based — there are no opaque "black box" calculations. It only acts on confirmation (the candle after the doji must close back through the range), which helps filter out many false signals that catch traders who enter on the doji itself. The ATR-based size filter and stop buffer adapt to changing volatility rather than using a fixed pip distance, and the fixed reward-to-risk structure enforces a defined exit plan on every trade.
Limitations. This is a counter-trend strategy, and counter-trend trading is inherently challenging: a doji at a swing high in a powerful uptrend can simply be a pause before the trend continues, producing a losing reversal trade. The strategy may underperform in strong, sustained trends where extremes keep extending, and it can be whipsawed in choppy, low-volatility conditions where many small dojis appear. Because it trades one position at a time, it can also miss follow-on opportunities. No pattern — the doji included — has predictive certainty; location and confirmation improve the odds of a sensible read, but they do not remove risk. Treat this EA as a structured way to study reversal behaviour, not as a guarantee of any outcome.
Risk Management Tips
Sound risk management matters far more than any single signal. Consider these general principles as part of your education:
- Risk a small, fixed fraction per trade. Many educational sources suggest risking no more than 1–2% of account equity on any single position, sized so that hitting the stop-loss costs only that amount.
- Size positions deliberately. The
Lotsinput should reflect your account size and the stop distance, not a number chosen at random. - Start on a demo account. Test the strategy in a risk-free demo environment first to understand how often it trades and how it behaves through different market conditions before considering real capital.
- Understand drawdown. Even a logically sound strategy will have losing streaks. Know the maximum drawdown you are willing to tolerate, and review whether the historical behaviour fits your temperament.
- Respect the stop-loss. The structural ATR-buffered stop exists to define your risk on every trade — overriding it removes the protection the strategy is built around.
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: DojiExtremeReversal.ex5 (5 downloads)
- Source Code: DojiExtremeReversal.mq5 (6 downloads)
- Documentation: DojiExtremeReversal.pdf (6 downloads)