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 Winsorized Momentum Trend strategy is a trend-following, robust-statistics momentum system for MetaTrader 5 that measures directional pressure using a winsorized drift rather than a raw momentum reading. In plain terms, "winsorizing" is a technique from robust statistics that clips extreme values back toward the bulk of the data instead of letting them dominate the calculation. Applied to price returns, this means a single violent spike bar — a news wick or a stop-run candle — is prevented from falsifying the trend signal, so the reading reflects the persistent lean of the market rather than one freak move that usually reverts.
Most simple momentum tools calculate something like Close[now] − Close[k bars ago] or the slope of a moving average. Both are easily distorted by one outsized bar. Winsorized Momentum Trend instead takes the last N bar-to-bar returns, finds their median and median absolute deviation (MAD), and pulls every return that lies beyond a robust-sigma band back to the edge of that band before summing them. The result is divided by the Average True Range (ATR) — a standard volatility measure — to produce a "clean drift in ATRs" that is comparable across symbols and timeframes.
This strategy is designed as a learning tool for traders who want to understand how robust statistics can filter noise out of a trend gauge, and how a pullback-entry (buying a dip within an uptrend rather than chasing a breakout) can be combined with a regime filter. It is best suited to liquid, trending instruments and is not intended as a turnkey system or a profit opportunity — it is a worked example of a design idea.
How It Works
The strategy recalculates its "clean drift" on every newly closed bar, then checks for entries, exits, and risk conditions. Here is the logic in plain English.
Building the clean drift (the trend gauge):
- The strategy takes the last MomentumPeriod bar-to-bar returns (each return is simply one close minus the previous close).
- It finds the median of those returns (a robust center) and the median absolute deviation, scaled by 1.4826 to act as a breakdown-resistant stand-in for standard deviation.
- Every return more extreme than WinsorK robust-sigmas is clipped back to the edge of the band — no bar is deleted, but a 6-sigma spike counts no more than a WinsorK-sigma move.
- The clipped returns are summed into a robust net displacement, then divided by ATR to give a scale-free drift in ATRs.
The strategy signals a LONG entry when:
- The clean drift is at or above +TrendThreshold ATRs (a robust uptrend is in force), and
- Price had dipped to or below the fast EMA on the prior bar (
prevClose ≤ prevEMA), and - Price now reclaims the EMA on the current close (
close > EMA) — a pullback that resumes, rather than a chase.
The strategy signals a SHORT entry when:
- The clean drift is at or below −TrendThreshold ATRs (a robust downtrend), and
- Price had popped to or above the fast EMA on the prior bar (
prevClose ≥ prevEMA), and - Price now loses the EMA on the current close (
close < EMA) — selling the rip.
Exit logic:
- A live trade is closed the moment the clean drift crosses back through zero against the position — that is, the robust regime itself has flipped. A long exits if drift turns non-positive; a short exits if drift turns non-negative.
Stop-loss and take-profit logic:
- On entry, a protective stop is placed AtrMultSl ATRs away from the fill price, capping the loss if price reverses hard before the drift flips.
- A take-profit target is placed AtrMultTp ATRs away — deliberately wider, to let a clean trend leg run.
- Only one position per magic number is allowed at a time, and an optional spread gate blocks entries when the spread is too wide.

Strategy Parameters
| Parameter | Default | Min | Max | Description |
|---|---|---|---|---|
| MomentumPeriod | 20 | 8 | 60 | Number of bar-to-bar returns that define the drift window. |
| WinsorK | 2.0 | 1.0 | 4.0 | Half-width of the winsorization band in robust sigmas (MAD × 1.4826). Lower values mean harsher clipping. |
| TrendThreshold | 0.75 | 0.20 | 2.50 | Minimum absolute clean drift (in ATRs) for the window to count as a real trend. |
| FastEmaPeriod | 10 | 3 | 30 | Fast EMA that the pullback must reclaim to trigger an entry. |
| AtrPeriod | 14 | 5 | 40 | ATR period used to scale the drift and size the stop and target. |
| AtrMultSl | 2.0 | 0.5 | 6.0 | Protective stop distance as a multiple of ATR. |
| AtrMultTp | 3.5 | 0.5 | 10.0 | Target distance as a multiple of ATR (lets a clean leg run). |
| MaxSpreadPoints | 30 | 0 | 200 | Skip entries when the spread (in points) exceeds this value (0 = no filter). |
| Lots | 0.10 | 0.01 | 1.00 | Trade volume in lots. |
| Magic | 5163 | 0 | 9,999,999 | Magic number identifying this EA's positions. |

Recommended Chart Settings
Winsorized Momentum Trend was built with liquid, trending instruments in mind — major FX pairs such as EURUSD and GBPUSD, and metals such as XAUUSD (gold). The design notes point to the M15 to H1 timeframes as the intended range, where there are enough clean bars to build a stable drift estimate without excessive noise.
That said, the strategy never hardcodes a timeframe — it runs on whatever timeframe the chart or backtest selects, using the primary symbol and period throughout. Because every market behaves differently, results will vary considerably across symbols, timeframes, brokers, and market conditions. Treat the recommended settings as a starting point for study and testing, not as an optimal configuration. Always validate any settings on your own data before drawing conclusions.
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
Strengths of the approach. The core idea — using winsorization to make a momentum gauge blind to outlier bars — is a thoughtful answer to a real problem. Genuine trends are built from many ordinary bars leaning the same way, while noise and traps tend to be a few outsized bars that snap back. By clipping the tails, the drift tends to flip direction only on a true regime change rather than on a single dramatic candle. The pullback-reclaim entry also avoids chasing extended moves, and the ATR-based stops and targets adapt to current volatility instead of using fixed pip distances.
Known limitations. Like all trend-following logic, this strategy can struggle in choppy, range-bound markets where price repeatedly crosses the fast EMA without a sustained trend — this may produce a series of small losing trades as the drift hovers near the threshold. The regime-flip exit is symmetric and reactive: it protects capital when the trend genuinely turns, but it can also close a position during a temporary counter-move that later resumes. The MAD and median calculations require a reasonably sized window to be meaningful, so very small MomentumPeriod values may make the drift noisy.
Where it may underperform. Expect weaker behavior during low-volatility consolidation, around major news releases (where spreads widen and gaps occur), and on illiquid instruments where the spread gate frequently blocks entries. As always, historical behavior in a backtest may not carry into live conditions.
Risk Management Tips
Risk management matters more than any single entry rule. Consider these general principles as part of your education:
- 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.
- Use a demo account first: Test the EA on a demo or simulated account until you understand exactly how and when it opens, manages, and closes positions.
- Understand drawdown: Even a well-designed trend strategy can have losing streaks. Study the maximum drawdown in testing and ask whether you could tolerate that experience with real capital.
- Respect the spread and costs: Commissions, swaps, and slippage erode results. The
MaxSpreadPointsgate helps, but real trading costs should be included in any evaluation. - Never over-leverage: Keep total exposure modest so that a cluster of correlated losses cannot threaten your account.
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: WinsorizedMomentumTrend.ex5 (57 downloads)
- Source Code: WinsorizedMomentumTrend.mq5 (57 downloads)
- Documentation: WinsorizedMomentumTrend.pdf (60 downloads)