Blog / Strategy
Strategy

Swing Failure Reversal EA for MT5

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 SwingFailureReversal EA is a pure price-action expert advisor for MetaTrader 5 that trades the swing failure pattern (also called a liquidity sweep or stop-hunt rejection) around horizontal support and resistance levels. Unlike most automated systems, it uses no indicators of any kind — no moving averages, no RSI, no ATR. It reads only raw candles and the swing pivots they form, making it a clean case study in how structure-based, counter-trend trading can be expressed in code.

A swing pivot is simply a local turning point on the chart: a swing high is a bar whose high is the strictest peak over a set number of bars on each side, and a swing low is the mirror image at the bottom. These pivots act as horizontal resistance and support. The strategy waits for price to briefly poke through one of these levels — sweeping the stop orders resting just beyond it — and then close back inside, leaving a long rejection wick. That failed break is the "swing failure" the EA is named for.

This is a reversal / counter-trend swing-trading approach, designed for liquid instruments that produce clean stop-runs, such as gold (XAUUSD) or major forex pairs like GBPUSD, on intraday timeframes like M15 or M30. As a learning tool it suits traders who want to understand how support/resistance, liquidity, and rejection wicks can be defined objectively, rather than discretionary chart-reading. It is best treated as an educational framework for studying price-action logic — not as a shortcut to results.

How It Works

The EA evaluates the market once per newly-closed bar, so it never reacts to incomplete candles. On each closed bar it identifies the most recent confirmed swing pivot and checks whether the bar that just closed represents a failed break of that level.

swing failure reversal MT5 EA
Illustrative example of the strategy’s entry and exit logic — not real trading results.

Strategy Parameters

Parameter Default Min Max Description
PivotLeftRight 3 2 8 Number of bars required on each side of a bar for it to qualify as a swing pivot. Higher values demand more significant, less frequent levels.
MinWickFrac 0.40 0.10 0.70 Minimum rejection-wick size, as a fraction of the signal bar's full range. Filters out weak pokes and demands a real rejection pin.
StopBufferFrac 0.15 0.00 1.00 Extra stop-loss buffer placed beyond the sweep extreme, as a fraction of the bar's range. Larger values give the trade more breathing room.
RewardRatio 2.00 1.00 5.00 Take-profit distance as a multiple of the structural stop distance. A value of 2.0 targets twice the risk.
Lots 0.10 0.01 1.00 Fixed order volume in lots for each trade.
Magic 6301 0 9,999,999 Unique identifier so the EA can track and manage only its own positions.

Recommended Chart Settings

This strategy was designed for liquid instruments with clean stop-runs, with XAUUSD (gold) and GBPUSD cited as natural candidates, on the M15 or M30 timeframes. These markets tend to produce the sharp pokes-and-rejections the swing failure pattern relies on. Keep in mind that the behaviour of any pattern shifts across instruments, sessions, and volatility regimes — a setting that looks responsive on gold may behave very differently on a quieter pair. Always study how the logic performs on your specific symbol and timeframe before drawing conclusions, and remember that results will vary across different market conditions.

Historical Backtest Results

Note: The figures below are from a historical backtest simulation. Backtests have inherent limitations — they do not account for slippage, requotes, spread widening, or psychological factors. These results should not be interpreted as a prediction of future performance.

No backtest data is available for this strategy at the time of writing. When a historical simulation is run, the key metrics to review — Net Profit, Profit Factor, Sharpe Ratio, Win Rate, Maximum Drawdown %, and Total Trades — should be evaluated together rather than in isolation. A counter-trend system like this one can show a modest win rate while still being studied for its reward-to-risk structure, so pay particular attention to drawdown depth and the number of trades in the sample before reading anything into the figures. Treat any future backtest strictly as a historical simulation, not a forecast.

How to Install on MetaTrader 5

What to Consider Before Using This EA

Strengths of this approach. Because the SwingFailureReversal logic is built entirely from candles and pivots, it is transparent and easy to reason about — there are no lagging indicator calculations to second-guess. The swing failure pattern targets a well-documented market behaviour (the failed breakout / liquidity sweep), and the structure-based stop placed beyond the actual sweep extreme is logical rather than arbitrary. Expressing both the stop buffer and target as fractions and multiples means the system adapts to different symbols and timeframes automatically.

Known limitations. Counter-trend strategies that fade breakouts face a recurring challenge: when a level genuinely breaks and a strong trend follows, repeated rejection signals can produce a series of stop-outs. The fixed reward-to-risk target does not adapt to momentum, so trades may be cut short in fast moves or exit just before extended runs. The EA also acts only on closed bars and holds a single position with no re-entry or trailing logic, which keeps it simple but means it cannot adapt mid-trade.

Where it may underperform. Strongly trending or news-driven markets, thin or illiquid symbols, and periods of erratic spread widening can all degrade the pattern's reliability. The swing failure setup works best where there is real liquidity to sweep; in choppy, low-participation conditions, "pokes" may be noise rather than meaningful rejections. View this EA as a structured way to study price-action reversals, not as a finished solution.

Risk Management Tips

Sound risk management matters more than any single entry signal. Consider these general principles as part of your education:

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

← Back to Blog