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 Exhaustion Gap Reversal is a pure price-action expert advisor built around the fair-value gap (FVG) pattern, traded in a counter-trend reversal style. A fair-value gap is a three-candle imbalance: when one impulsive middle candle moves so quickly that the high of the candle before it never overlaps the low of the candle after it, the chart is left with a small "void" or inefficiency in price. Many traders treat that void as future support or resistance. This strategy takes the opposite view in one specific situation — when the gap is a sign of exhaustion rather than strength.
The key idea is that not every gap means continuation. When the impulsive candle that creates the gap also drives price to a fresh swing extreme — a brand-new high in an up-move, or a brand-new low in a down-move — that final thrust is often a late-stage liquidity grab rather than the beginning of a new leg. In this reading, the gap is the "last gasp" of an over-extended side of the market. The Exhaustion Gap Reversal strategy is designed to identify these end-of-move imbalances and trade the snap-back against the thrust: it signals a sell after an exhausted up-gap and a buy after an exhausted down-gap.
This EA is best suited as a learning tool for traders who want to study mean-reversion logic, fair-value-gap geometry, and the difference between continuation and reversal interpretations of the same pattern. It uses no traditional indicators at all — every decision comes from candle geometry. It was built with FX majors and gold (XAU) on the M15–H1 timeframes in mind, but it is not locked to any particular timeframe. If you are still learning how price action and order-flow concepts translate into mechanical rules, this strategy offers a clear, transparent example to dissect.
How It Works
The strategy runs two small "state machines" — one watching for exhausted up-gaps and one watching for exhausted down-gaps. It only acts once per fully closed bar, so it never reacts to an unfinished candle. Here is the logic in plain English.
Detecting an exhaustion gap (the setup):
- The strategy looks at the three newest closed candles. It labels them candle 1 (oldest), candle 2 (the impulse), and candle 3 (newest).
- For a bull exhaustion gap, it requires that candle 1's high is below candle 3's low (a genuine upward fair-value gap) and that candle 2 closed higher than it opened.
- The size of the gap must be large enough to matter. The strategy measures the average candle range over the
Lookbackwindow and requires the gap to be at leastMinGapFactortimes that average. This scales the filter to current volatility. - Crucially, the highest point of the three candles must be a new high versus the recent lookback window. That fresh extreme is what marks the move as exhausted rather than a healthy continuation.
- When all of this is true, the strategy arms a sell setup, recording the gap's two edges and the exhaustion high as a protective reference.
- The mirror logic arms a buy setup when a downward gap drives price to a fresh new low.
Confirming the entry (the trigger):
- An armed setup does not trade immediately. The strategy waits for a later candle to close back into the imbalance.
- For an armed sell, the strategy signals a short only when a subsequent candle closes bearishly and travels back down past the
FillFractionlevel of the gap — meaning price has snapped back into the void it left behind. - For an armed buy, it signals a long only when a later candle closes bullishly and pushes back up past the
FillFractionlevel. - The setup is invalidated if price instead closes at a new extreme beyond the thrust (a new high for a sell setup, a new low for a buy setup) — that would suggest the move was real continuation, not exhaustion.
- An armed setup also expires automatically after
ConfirmExpirybars if no confirmation appears, keeping stale signals from firing.
Stop-loss logic:
- The protective stop sits just beyond the exhaustion extreme — above the thrust high for a short, or below the thrust low for a long.
- The buffer is set by
StopBufferPct, expressed as a fraction of the gap's height. This places the stop in the zone where the trapped side of the market would be run out.
Take-profit logic:
- The target is a fixed reward-to-risk multiple defined by
RewardRisk. The distance from entry to stop is the "risk," and the take-profit is placed that distance multiplied by the reward factor away from entry.
The strategy also keeps things simple by trading only one position at a time per symbol, and it manages armed setups before detecting new ones so that a single candle can never both arm and trigger a trade.

Strategy Parameters
| Parameter | Default | Min | Max | Description |
|---|---|---|---|---|
| Lookback | 20 | 8 | 60 | Number of prior bars used to measure the swing extreme and the average candle range. |
| MinGapFactor | 0.35 | 0.05 | 2.00 | Minimum gap size required, expressed as a fraction of the average candle range. Higher values demand larger, rarer gaps. |
| FillFraction | 0.50 | 0.10 | 1.00 | How far price must close back into the gap before a reversal is confirmed. 0.50 means halfway into the imbalance. |
| ConfirmExpiry | 6 | 1 | 25 | Number of bars an armed setup stays valid while waiting for confirmation before it expires. |
| RewardRisk | 2.0 | 1.0 | 6.0 | Reward-to-risk multiple used to place the take-profit relative to the stop distance. |
| StopBufferPct | 0.25 | 0.00 | 1.50 | Extra stop-loss buffer beyond the exhaustion extreme, expressed as a fraction of the gap height. |
| Lots | 0.10 | 0.01 | 1.00 | Fixed trade volume in lots. |

Recommended Chart Settings
This strategy was designed with FX major pairs and gold (XAU) in mind, on the M15 to H1 timeframes, where fair-value gaps and exhaustion thrusts tend to be clean and meaningful. That said, the code is deliberately not locked to any timeframe — it runs on whatever primary chart you attach it to. Because the gap filter scales to volatility through the average-range calculation, the same parameters can behave differently on a fast-moving instrument than on a slow one. Treat the defaults as a starting point for study, and remember that results will vary considerably across symbols, sessions, and changing market conditions.
How to Install on MetaTrader 5
- Download the
.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
The strength of the Exhaustion Gap Reversal approach is its clarity and discipline. It defines exhaustion mechanically — a real fair-value gap plus a fresh swing extreme plus a confirmed snap-back — rather than relying on subjective judgment. The confirmation requirement and the expiry window help filter out gaps that simply keep running, and the fixed reward-to-risk structure enforces a consistent risk profile on every trade.
The limitations are equally important to understand. Counter-trend reversal systems, by design, trade against momentum, which means a strong trending market can produce a string of losing signals when "exhaustion" gaps turn out to be genuine continuation. The strategy's invalidation rule (a new extreme cancels the setup) helps, but it cannot eliminate the core risk that fading a strong move carries. Performance is also sensitive to spread and slippage, particularly on lower timeframes and around news events where gaps are most common. Periods of low volatility may produce few qualifying gaps at all, while choppy ranges can produce frequent small setups that whipsaw. No parameter set works equally well across every market regime, and over-tuning the inputs to past data can create a strategy that looks impressive in review but adapts poorly to new conditions. Use this EA as a framework for learning how reversal logic behaves — not as a finished, hands-off system.
Risk Management Tips
Sound risk management matters far more than any single entry rule. As you study this strategy, keep these general principles in mind:
- Position sizing: Size each trade so that a stop-out costs only a small, predefined fraction of your account. A common educational guideline is to risk no more than 1–2% of account equity per trade.
- Test on a demo account first: Run the EA on a demo or simulated account until you fully understand how it behaves across different sessions and market conditions before considering any live use.
- Understand drawdown: Every strategy experiences losing streaks. Know the historical drawdown range you are studying and ask yourself whether you could stay disciplined through an equivalent stretch.
- Account for costs: Spread, commission, and slippage all reduce real-world outcomes versus an idealized backtest — especially for a strategy that trades around volatile gaps.
- Avoid over-leverage: Leverage amplifies both gains and losses. Conservative leverage gives a strategy room to survive normal variance.
- Keep parameters realistic: Resist the urge to over-optimize inputs to fit past data. Robust settings that work across a range of conditions are generally more instructive than a perfectly curve-fitted set.
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: ExhaustionGapReversal.ex5 (3 downloads)
- Source Code: ExhaustionGapReversal.mq5 (5 downloads)
- Documentation: ExhaustionGapReversal.pdf (4 downloads)