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 Imbalance Magnet Reversal is a pure price-action, counter-trend (mean-reversion) strategy that uses two raw chart structures — swing support/resistance levels and Fair Value Gaps (FVGs, also called imbalances) — without relying on a single technical indicator. There is no moving average, RSI, ATR, or Bollinger Band anywhere in its logic. Instead, it reads the geometry of recent candles directly, which makes it a useful study tool for traders who want to understand how structure and liquidity interact on a clean chart.
A swing support or resistance level is a horizontal price where the market previously turned. The strategy confirms these from fractal pivots — a candle whose high tops (or whose low bottoms) every neighboring candle for a set number of bars on both sides. A Fair Value Gap is a three-candle pattern where the middle candle moves so quickly that the first and third candles leave an untraded "pocket" of price behind. In classic Smart Money Concepts theory, the market is often drawn back to fill these voids, so an unfilled gap can act like a magnet for future price movement.
What makes this approach distinctive is that it inverts the usual "trade the gap" playbook. Most FVG systems enter inside the gap. Here, the gap is never the entry — it is only the target. The entry is a clean rejection off a swing level, and the unfilled imbalance becomes the destination the strategy aims for. It was built with EUR/USD or XAU/USD (gold) on the M15 timeframe in mind, and it is best suited to intermediate learners who already grasp candlestick anatomy and want to see how structure-based, no-indicator logic can be coded.
How It Works
The strategy evaluates the market once per freshly closed candle and only ever holds one position at a time. Before any signal is considered, it builds a simple volatility scale by averaging the candle range (high minus low) over the lookback window, so every threshold automatically adapts to the symbol and current conditions without needing the instrument's point size.
Entry conditions — the strategy signals a trade when:
- A new bar has just closed and there is no open position for this strategy's magic number.
- The current spread is at or below the
MaxSpreadPointsfilter (wide spreads are skipped). - Confirmed fractal swing levels have been harvested from closed bars only, so the levels never repaint.
- For a short: the just-closed candle is bearish (closes below its open), its wick pierced up into a swing resistance level (within the touch zone), but its body closed back below that level — proving the ceiling held.
- For a long (the mirror): the candle is bullish (closes above its open), its wick dipped down into a swing support level, but its body closed back above it — proving the floor held.
Take-profit logic — the magnet:
- After a valid rejection, the strategy searches recent bars for the nearest still-unfilled Fair Value Gap lying in the trade's direction.
- For a short, it looks for the nearest unfilled gap below price; for a long, the nearest unfilled gap above price.
- A gap must be at least
MinGapFracof the average range to count (this filters out tiny noise gaps), and it is discarded if any later candle has already traded fully through it. - The near edge of that qualifying gap becomes the take-profit target.
Stop-loss logic:
- For a short, the stop is placed just above the rejected level or the signal candle's high (whichever is higher), plus a buffer.
- For a long, the stop is placed just below the rejected level or the candle's low, minus a buffer.
- The buffer size is
StopBufferFracof the average candle range.
Reward-to-risk filter:
- The distance from entry to the magnet target (reward) is divided by the distance from entry to the stop (risk).
- If that ratio is below
MinRewardRisk, the setup is skipped entirely. Only trades that meet the minimum reward:risk are sent.
Both the structural stop and the imbalance target manage the exit — there is no separate trailing or time-based close.

Strategy Parameters
| Parameter | Default | Min | Max | Description |
|---|---|---|---|---|
| Lots | 0.10 | 0.01 | 1.00 | Fixed order volume in lots for each trade. |
| PivotLeg | 3 | 2 | 8 | Bars required on each side to confirm a fractal swing pivot. Higher values mean stronger, rarer levels. |
| SrLookback | 60 | 20 | 200 | How many recent closed bars to scan for swing levels and the volatility scale. |
| TouchZoneFrac | 0.15 | 0.02 | 1.00 | How close (as a fraction of mean candle range) the wick must come to a level to count as a "touch." |
| GapLookback | 40 | 6 | 150 | How many recent closed bars to scan for an unfilled magnet gap. |
| MinGapFrac | 0.25 | 0.05 | 1.50 | Minimum gap height as a fraction of mean candle range; rejects noise gaps. |
| StopBufferFrac | 0.15 | 0.00 | 1.00 | Stop buffer beyond the rejected level or signal-candle extreme, as a fraction of range. |
| MinRewardRisk | 1.00 | 0.30 | 5.00 | Minimum reward-to-risk ratio to the magnet target; below this the setup is skipped. |
| MaxSpreadPoints | 100 | 5 | 300 | Skip entries when the spread (in points) is wider than this value. |
| Magic | 7340 | 0 | 9,999,999 | Unique identifier so the EA only manages its own positions. |

Recommended Chart Settings
This strategy was designed and tuned with EUR/USD or XAU/USD (gold) on the M15 (15-minute) timeframe in mind, but its volatility-scaled thresholds mean it can run on any liquid instrument and timeframe the chart provides — it reads only the primary symbol and timeframe of the chart it is attached to. Because the logic adapts to the average candle range automatically, you do not need to re-tune point-based settings when switching symbols. That said, results will vary considerably across different instruments, sessions, and market conditions, so always validate behavior on each market separately before drawing conclusions.
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. Because the Imbalance Magnet Reversal uses no indicators, it avoids the lag and curve-fitting that indicator-based systems can introduce. Its levels are built only from closed bars, so they never repaint — what you see in a backtest is what the logic actually saw in real time. The structured "rejection in, imbalance out" framework also enforces a defined risk and a defined target on every trade, which is a healthy discipline to study.
Known limitations. Counter-trend, mean-reversion systems share a well-documented weakness: in a strong, sustained trend, support and resistance levels break rather than hold, and a strategy that keeps fading those levels can suffer repeated losses. The Fair Value Gap target may also remain unfilled for a long time — or never fill — which can leave trades hanging or missing. The single-position rule means the EA can sit idle while opportunities pass, and the spread filter will block entries entirely during volatile news periods when spreads widen.
Where it may underperform. Expect weaker behavior during low-liquidity hours, around major news releases, and in trending environments where price slices straight through structure. The fractal pivot confirmation also introduces a natural delay — a level is only confirmed after enough bars form on both sides — so the strategy may identify structure later than a discretionary trader would. Treat it as an educational illustration of structure-and-liquidity logic, not a finished trading system.
Risk Management Tips
Sound risk management matters more than any single strategy. Consider these general principles as part of your learning:
- Risk a small, fixed fraction per trade. Many educators suggest never risking more than 1–2% of account equity on a single position. Size your lots so that the distance to the stop reflects that limit.
- Test on a demo account first. Run the EA on a demo or paper account across many market conditions before considering anything else. This costs nothing and teaches you how the logic behaves.
- Understand drawdown. Every strategy experiences losing streaks. Know the maximum peak-to-trough decline you are willing to tolerate, and stop to reassess if it is reached.
- Account for costs. Spread, commission, and slippage all eat into theoretical results, especially on lower timeframes and during volatile sessions.
- Diversify your study. Do not rely on one EA or one symbol. Comparing behavior across markets builds a more realistic understanding of an approach's edge and its limits.
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: ImbalanceMagnetReversal.ex5 (0 downloads)
- Source Code: ImbalanceMagnetReversal.mq5 (0 downloads)
- Documentation: ImbalanceMagnetReversal.pdf (1 downloads)