Blog / Strategy
Strategy

Ulcer Index Trend Pullback

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 Ulcer Index Trend Pullback is a trend-continuation strategy — a "buy the dip in an uptrend" (and "sell the rally in a downtrend") system — built around a quality filter that few retail traders ever use: Peter Martin's Ulcer Index. The Ulcer Index is a volatility measure that only counts downside pain. Instead of treating all price movement as risk, it measures the root-mean-square of the percentage drawdowns from a running peak, so it captures how smooth or how jagged a trend has been rather than simply how far price has travelled.

Most trend filters answer a single question: is price above a moving average and is that average rising? They say nothing about how price got there. A market can rise two percent by gliding calmly higher, or rise two percent through a violent saw-tooth that stops out every pullback trader along the way. The Ulcer Index Trend Pullback strategy adds this missing dimension. It only takes a pullback entry when the preceding trend has been orderly — a low Ulcer Index reading — because retracements tend to continue far more reliably inside a calm advance than inside a whipsawing one.

As a learning tool, this strategy is well suited to traders who already understand moving averages and want to explore a more nuanced idea of trend quality. It combines several classic building blocks — a baseline Simple Moving Average (SMA) for direction, a fast Exponential Moving Average (EMA) for the pullback, an Average True Range (ATR) for risk, and the Ulcer Index as a texture gate. Studying how these pieces interact is a useful exercise in thinking about market conditions rather than chasing signals in isolation.

How It Works

The strategy evaluates its rules only on closed bars, so signals do not repaint intrabar. On each newly closed bar it checks a symmetric set of conditions for longs and shorts.

Trend direction (the baseline filter):

Trend quality (the Ulcer Index gate):

The pullback and resume (timing the entry):

Stop-loss and take-profit logic:

Trade management:

Ulcer Index trend pullback MT5
Illustrative example of the strategy’s entry and exit logic — not real trading results.

Strategy Parameters

Parameter Default Min Max Description
UlcerPeriod 14 5 40 Window (bars) for the Ulcer Index drawdown/draw-up measurement.
TrendPeriod 50 20 200 Length of the baseline SMA that defines trend direction.
SlopeLookback 5 1 20 How many bars back to measure the baseline SMA slope (rising or falling).
PullbackPeriod 10 3 30 Length of the fast EMA that price pulls back to before resuming with the trend.
UlcerThreshold 1.5 0.2 6.0 Maximum Ulcer Index (percent) for the trend to count as "smooth" enough to trade.
AtrPeriod 14 5 30 ATR lookback used to size the stop distance.
AtrStopMult 2.0 0.5 5.0 Stop distance as a multiple of ATR beyond the entry.
RewardRisk 1.8 0.5 5.0 Take-profit as a reward:risk multiple of the ATR stop distance.
MaxSpreadPoints 80 5 300 Skip new entries when the current spread (points) is wider than this.
Lots 0.10 0.01 1.0 Fixed trade volume in lots.
Magic 5182 0 9,999,999 Magic number identifying this EA's trades.
Ulcer Index trend pullback MT5 — MQL5 source code

Recommended Chart Settings

The Ulcer Index Trend Pullback was designed with trending instruments in mind — a trending FX major or an index such as EURUSD, GBPUSD, or US500 — on swing-style timeframes between H1 and H4. These markets tend to produce the sustained, orderly moves that the Ulcer Index gate is built to reward, and the higher timeframes reduce the noise that triggers false pullback signals.

That said, the strategy reads only the primary timeframe of the chart it is attached to, so it will run on whatever symbol and timeframe you select at backtest or live time. Behaviour can change meaningfully across instruments and market regimes, and results will vary across different market conditions. Test any combination thoroughly on historical data and a demo account before drawing conclusions.

How to Install on MetaTrader 5

What to Consider Before Using This EA

The strongest idea in this strategy is its use of trend quality, not just trend direction. By screening for smooth advances, the Ulcer Index filter is designed to avoid pullback entries in jagged, whipsawing markets where retracements are more likely to fail. Combining an ATR-based stop with a fixed reward:risk target also keeps risk self-scaling and consistent across volatility regimes, which is good practice to study.

There are real limitations to keep in mind. Trend-continuation systems, by nature, struggle in ranging or choppy markets — the Ulcer Index gate reduces but does not eliminate this exposure, and a market can transition from smooth to jagged after an entry is already open. A low Ulcer Index reading is backward-looking: it describes the trend that has happened, not what will happen next. Sharp reversals and news-driven spikes can still trigger the ATR stop. The strategy also takes a single position at a time with no trailing exit, so it may give back open profit if a move stalls before reaching the target. Finally, moving-average and pullback logic inherently lags, meaning the entry arrives after the resume rather than at the turn.

None of this makes the approach good or bad — it makes it a specific tool for a specific condition. The goal of studying it is to understand when that condition is present and when it is not.

Risk Management Tips

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