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 Semivariance Reversion Fade is a mean-reversion trading strategy for MetaTrader 5 built around an idea borrowed from the Sortino ratio: semivariance, which measures the volatility of downside moves and upside moves separately rather than lumping them into a single symmetric number. Most envelope-reversion systems — Bollinger Bands, z-score bands, standard-deviation channels — assume the market wobbles equally in both directions, so their upper and lower rails are mirror images. The Semivariance Reversion Fade rejects that assumption and hangs an asymmetric envelope around a moving-average "fair value" line, scaling the lower rail by downside volatility and the upper rail by upside volatility.
Mean reversion is the trading style at the heart of this system. The core belief is that when price stretches unusually far from a rolling average, it tends to snap back toward that average — and the strategy "fades" (trades against) the stretch, buying when price is over-extended below the lower rail and selling when it is over-extended above the upper rail. Because the two rails breathe independently, the system naturally widens the rail on whichever side is currently more volatile, which helps it avoid fighting one-sided pressure.
As a learning tool, this strategy is well suited to traders who already understand basic moving averages and want to explore how volatility skew — the tendency for down-moves and up-moves to behave differently — can be encoded directly into an entry filter. It is not a "set and forget" money machine; it is a structured example of adaptive, self-scaling logic. Treat it as a case study in asymmetric risk modeling and disciplined mean-reversion design.
How It Works
The strategy acts once per newly-closed bar on the chart's timeframe. It maintains a rolling history of closed bars and computes several ingredients before deciding whether to trade.
Building the fair-value baseline and rails:
- The baseline is an Exponential Moving Average (EMA) of closing prices over
MeanPeriodbars. An EMA is a moving average that weights recent prices more heavily, giving a responsive "fair value" line. - Returns (
close ÷ previous close − 1) are collected over the lastDevPeriodbars. Their average ismeanR. - Downside semideviation is the root-mean-square of returns that fell below the average; upside semideviation is the same for returns above the average. These two numbers describe how sharply the market typically drops versus rises.
- The lower rail sits at
baseline × (1 − DownMult × downside deviation)and the upper rail atbaseline × (1 + UpMult × upside deviation). Because each side uses its own volatility, the envelope is asymmetric and self-adjusting.
Entry conditions — the strategy signals a LONG when:
- The freshly-closed bar's close is below the lower rail (price is over-stretched to the downside relative to normal downside volatility), AND
- That bar is bullish (close above open), suggesting the snap-back may already be starting, AND
- The market is not in a strong directional grind (see the trend guard below).
A SHORT is the mirror image: the close is above the upper rail, the bar is bearish (close below open), and no strong grind is present.
The trend guard: the strategy measures the EMA baseline's slope per bar. If the absolute slope exceeds TrendGuardAtr × ATR, the baseline is moving directionally faster than a chosen fraction of average true range, and the strategy stands aside entirely. This veto is what stops the system from repeatedly fading a strong trend — historically the most dangerous thing a reversion system can do.
Exit logic:
- Every position carries a broker-side stop-loss placed
AtrStopMult × ATRbeyond the entry price. ATR (Average True Range) measures recent volatility, so the stop scales with market conditions. - The take-profit is set at the EMA baseline — the "magnet" price the strategy expects the market to revert toward.
- Because the baseline keeps drifting, there is also an adaptive exit: if a later closed bar prints back through the current baseline, the position is closed immediately, banking the completed reversion rather than waiting for the original target.
- A reward-to-risk filter rejects any setup where the distance to the baseline target is smaller than
MinRewardRisktimes the stop distance, and a spread filter skips entries when the current spread is too wide. Only one position per magic number is held at a time.

Strategy Parameters
| Parameter | Default | Min | Max | Description |
|---|---|---|---|---|
| MeanPeriod | 20 | 10 | 60 | EMA lookback for the fair-value baseline that the rails hang from and that serves as the take-profit target. |
| DevPeriod | 40 | 20 | 120 | Number of bars used to measure the downside/upside semideviation of returns. |
| DownMult | 2.2 | 1.0 | 4.0 | Width of the lower rail as a multiple of downside semideviation. |
| UpMult | 2.2 | 1.0 | 4.0 | Width of the upper rail as a multiple of upside semideviation. |
| TrendGuardAtr | 0.30 | 0.05 | 1.5 | Skip fades when the baseline's per-bar slope exceeds this multiple of ATR. |
| AtrPeriod | 14 | 5 | 30 | Lookback period for the ATR used to size the protective stop. |
| AtrStopMult | 1.8 | 0.5 | 4.0 | Protective stop distance beyond entry, as a multiple of ATR. |
| MinRewardRisk | 0.8 | 0.3 | 3.0 | Minimum acceptable reward-to-risk ratio; setups below this are rejected. |
| MaxSpreadPoints | 80 | 5 | 300 | Skip new entries when the current spread (in points) is wider than this. |
| Lots | 0.10 | 0.01 | 1.0 | Fixed order volume in lots. |
| Magic | 5271 | 0 | 9,999,999 | Unique identifier so the EA manages only its own trades. |

Recommended Chart Settings
The Semivariance Reversion Fade is single-timeframe and self-scaling: every calculation uses the chart's own timeframe, so it adapts to whatever period you attach it to. It was designed with liquid FX majors and metals in mind — for example EURUSD, GBPUSD, or XAUUSD — on the M15 to H1 timeframes, where volatility skew and mean-reversion tendencies both tend to appear.
These are starting points for study, not guarantees. Volatility skew, spread behavior, and reversion strength differ across instruments and sessions, so results will vary considerably across different market conditions. Always test any symbol/timeframe combination on your own data 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 of the approach. The asymmetric envelope is the standout idea. By measuring downside and upside volatility separately, the strategy widens the rail on whichever side the market is currently more active — which means that in a sell-off the downside deviation balloons, the lower rail drops away, and casual long-fades stop firing exactly when fading a downtrend would be most dangerous. The EMA-slope trend guard adds a second, independent veto against trading into strong momentum. Everything is self-scaling: the rails, the ATR stop, and the structural EMA target all adapt to volatility rather than relying on fixed pip distances.
Known limitations. Mean-reversion systems are, by design, vulnerable to sustained trends and regime shifts. Semivariance and the trend guard reduce that exposure but cannot eliminate it — a fast, gapping breakout can blow through a rail before the guard's slope estimate catches up. The strategy also assumes reversion actually occurs; in a strongly trending or news-driven market, price may keep stretching rather than snapping back. Because only one position per magic is held, the system trades selectively and may sit idle for long stretches, which is normal but can feel unproductive.
Where it may underperform. Expect weaker behavior during strong directional trends, low-liquidity sessions with erratic spreads, and around major economic releases when volatility skew changes abruptly. Historically, mean-reversion logic tends to do best in ranging, oscillating conditions and worst in one-way markets. This strategy is a tool for studying that trade-off, not a shortcut around it.
Risk Management Tips
Sound risk management matters far more than any single indicator. Consider these general principles as part of your education:
- Position sizing: Keep individual trade risk small. Many educational sources suggest risking no more than 1–2% of account equity on any single trade. Adjust the
Lotsparameter so the ATR-based stop distance stays within that limit. - Use a demo account first: Run the EA on a demo account across varied market conditions before ever considering live capital. This lets you observe how the asymmetric rails and trend guard behave in practice.
- Understand drawdown: Every strategy experiences losing streaks. Study the depth and duration of drawdown you would have to sit through before deciding whether an approach fits your temperament.
- Diversify and avoid over-leverage: Concentrating risk in one instrument or using excessive leverage magnifies losses. Leverage cuts both ways.
- Review regularly: Markets evolve. Parameters that suited one regime may not suit another, so revisit your settings and assumptions periodically.
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: SemivarianceReversionFade.ex5 (35 downloads)
- Source Code: SemivarianceReversionFade.mq5 (33 downloads)
- Documentation: SemivarianceReversionFade.pdf (35 downloads)