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 Inverted Gap Limit Continuation is a pure price-action trading system built around the Inversion Fair-Value Gap (IFVG) concept. A fair-value gap (FVG) is a three-candle imbalance — a fast middle candle leaves an "untraded void" so that, for a bullish gap, the high of the oldest candle sits below the low of the newest. Most gap strategies treat that void as support or resistance that should hold. This strategy does the opposite: it trades the moment a void fails, when price closes clean through the gap and simultaneously breaks market structure. The trading style is break-of-structure continuation with passive limit-order entries.
What sets this approach apart is that it uses no technical indicators whatsoever — no moving averages, no oscillators, no momentum studies. Every level, filter, stop and target is derived from raw candle geometry. The single average it computes is a plain mean candle range, used only to scale the minimum-gap filter to current volatility. The system also adds a structure gate: a gap only "inverts" if the breaking candle also clears the most recent fractal swing (a pivot confirmed by a set number of bars on each side), tying every signal to a genuine break of structure rather than a simple body-size move.
As a learning tool, this EA is well suited to traders studying institutional-style concepts such as fair-value gaps, liquidity, and order-flow shifts. It is designed with FX majors, gold (XAU), and index CFDs on M5 to H1 timeframes in mind, though it is not locked to any single timeframe. Treat it as a framework for understanding how a failed imbalance can flip into a fresh supply or demand zone — not as a shortcut to results.
How It Works
The strategy processes one freshly-closed bar at a time and walks through a fixed pipeline of pure-geometry steps.
- Tracking fair-value gaps: On each closed bar, the strategy checks the last three candles for a fresh FVG. A bullish gap forms when the oldest candle's high is below the newest candle's low, the middle candle is bullish, and the gap is at least
MinGapFactor× average candle range. A bearish gap is the mirror image. Each qualifying gap is stored and given an expiry. - Confirming market structure: A fractal swing high or low is confirmed when a pivot bar's high (or low) dominates
SwingStrengthbars on each side. The most recent confirmed swing levels are kept on hand to gate inversions. - Detecting the inversion (entry signal): The strategy signals an inverted supply when a bar closes below a bullish gap and below the last swing low — the bullish void has failed and flipped into resistance. It signals an inverted demand when a bar closes above a bearish gap and above the last swing high. Requiring both conditions ensures the gap failure coincides with a real structure break.
- Resting a passive limit: Rather than chasing the move with a market order, the strategy parks a limit order back inside the inverted void. For inverted supply it rests a sell-limit; for inverted demand it rests a buy-limit. The
EntryDepthparameter controls how deep into the void the order sits (0 = first touch, 1 = deepest edge), letting price retrace to you. - Stop-loss logic: The protective stop is placed beyond the void's far edge, padded by
StopBufferPctof the void height. For a sell the stop sits above the void; for a buy it sits below. This anchors risk to the structure that defined the signal. - Take-profit logic: The target is a fixed multiple of the measured risk, set by
RiskReward. With the default of 2.0, the reward distance is twice the stop distance. - Break-even trail: Once an open trade runs
BreakEvenRmultiples of its initial risk in your favour, the stop is pulled to the entry price (once per trade), reducing exposure on trades that move the right way early. - Order housekeeping: A resting limit is cancelled if price "reclaims" the void (closes back through it) or if it ages past
LimitExpirybars. Un-inverted gaps are dropped afterFvgExpirybars. The system manages only one resting limit or open position at a time and never stacks orders.

Strategy Parameters
| Parameter | Default | Min | Max | Description |
|---|---|---|---|---|
| MinGapFactor | 0.20 | 0.05 | 1.50 | Minimum gap size as a fraction of the average candle range — filters out trivial imbalances. |
| RangeLookback | 20 | 10 | 60 | Number of bars used to compute the mean candle range for the gap filter. |
| SwingStrength | 2 | 1 | 5 | Fractal pivot strength — bars required on each side to confirm a swing high/low. |
| EntryDepth | 0.50 | 0.00 | 1.00 | How deep the limit order rests inside the inverted void (0 = first touch, 1 = deepest edge). |
| StopBufferPct | 0.25 | 0.00 | 1.50 | Stop buffer beyond the void's far edge, as a fraction of the void height. |
| RiskReward | 2.0 | 1.0 | 6.0 | Fixed reward-to-risk multiple used to set the take-profit. |
| BreakEvenR | 1.0 | 0.0 | 4.0 | Move the stop to entry after the trade runs this many multiples of risk in profit (0 disables). |
| FvgExpiry | 20 | 3 | 60 | Number of bars an un-inverted gap survives before being discarded. |
| LimitExpiry | 12 | 2 | 50 | Number of bars a resting limit order survives before being cancelled. |
| Lots | 0.10 | 0.01 | 1.00 | Fixed trade volume in lots. |

Recommended Chart Settings
This strategy was tuned with FX majors, gold (XAU), and index CFDs in mind, on timeframes from M5 to H1. It is not locked to any particular timeframe and will run on whatever primary chart you attach it to. Lower timeframes produce more frequent gaps and more signals but also more noise; higher timeframes produce fewer, larger setups. As always, results will vary considerably across different instruments, spreads, and market conditions, so test on the specific symbol and timeframe you intend to study.
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
On the strength side, this approach is built on a clear, repeatable logic. Because it uses no indicators, there is nothing to lag or repaint — every decision comes from candle structure you can see and verify on the chart. The double requirement of a gap failure and a structure break is a meaningful filter that historically helps avoid trading every minor poke through a void. Passive limit entries also mean you only participate when price retraces to a defined level, and the break-even trail offers active management that many simpler gap systems lack.
The limitations are equally important to understand. Continuation systems built on break-of-structure can suffer in ranging or choppy markets, where price repeatedly fakes breaks and reclaims voids — generating cancelled orders or stop-outs. Limit entries that wait for a retrace may miss strong, one-directional moves entirely when price never comes back to fill. The fixed reward-to-risk target does not adapt to volatility, so the same RiskReward setting may be too tight in trending conditions and too ambitious in quiet ones. Parameter choices like EntryDepth, MinGapFactor, and SwingStrength interact in non-obvious ways, and over-tuning them to past data may not carry forward. As with any EA, spread, slippage, and broker stop-level rules can materially change real-world behaviour versus a clean backtest.
Risk Management Tips
- Use a demo account first. Study how the strategy behaves across different sessions and instruments before committing any capital.
- Risk a small, fixed fraction per trade. A common educational guideline is risking no more than 1–2% of account equity on any single position, and sizing
Lotsaccordingly rather than using a large fixed volume. - Understand drawdown. Even a sound strategy can experience long losing streaks. Know the maximum drawdown you are emotionally and financially prepared to tolerate.
- Account for costs. Spreads, commissions, and swap can erode results, especially on lower timeframes with frequent activity.
- Avoid over-optimisation. Tuning parameters until a backtest looks perfect often produces a curve-fit that fails on new data. Prefer robust settings that work reasonably across a range of conditions.
- Diversify and monitor. Do not rely on a single EA or instrument, and keep an eye on live behaviour rather than leaving automation entirely unattended.
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: InvertedGapLimitContinuation.ex5 (6 downloads)
- Source Code: InvertedGapLimitContinuation.mq5 (4 downloads)
- Documentation: InvertedGapLimitContinuation.pdf (3 downloads)