Gold Regime Portfolio: Two Trend Models, One Risk Budget for XAUUSD
Gold can spend hours moving sideways and then travel a substantial distance in a short period. For a systematic trader, the challenge is not simply identifying an uptrend. It is deciding whether the trend has sufficient strength, how much risk to allocate to an entry, and what to do when two models identify the same opportunity.
Gold Regime Portfolio is an MT5 Expert Advisor I developed as an implementation of two long-only trend-following models. This article explains its design and the questions I would examine before interpreting any test results. It is a technical discussion of the methodology, not a trading recommendation or a claim of profitability.
1. Two interpretations of an H1 trend
Both models use completed candles, rather than treating an intrabar change in an indicator as a confirmed signal. They differ in how they define trend context and the conditions under which they may participate.
- Model A — shorter EMA structure: EMA 8/30 and an ADX threshold of 30. A configurable rollover filter based on broker server time helps control when new entries can be considered around rollover.
- Model B — broader trend context: EMA 8/50 and an ADX threshold of 35, with a bullish D1 trend filter. The daily filter adds a higher-timeframe directional condition.
ADX is a measure of trend strength, not direction by itself. The EMA relationships and directional conditions therefore matter alongside the ADX filter. The models use ATR-based protective stops, defined profit targets and a maximum holding time of 24 hours.
Neither model is intended to trade every price movement. A higher threshold can remove weak trends, but it can also exclude opportunities. That trade-off is a research question, not something that should be assumed to improve performance automatically.
2. Two signals do not necessarily mean twice the risk
Suppose two models are both interested in buying gold. Although their rules are different, they are still exposed to the same underlying instrument and may lose together. Giving each a full, independent risk budget can unintentionally increase total exposure.
The shared-risk implementation of Gold Regime Portfolio addresses this by allocating an aggregate target for initial stop risk across the models. In split-risk mode, the allocation is divided according to the configured settings; individual and single-position modes are also available. On a netting account, the EA uses a single-position implementation because independent positions on the same symbol cannot be maintained.
Consider a purely illustrative account with 10,000 units of equity and the default aggregate initial stop-risk target of 0.25%:
- Aggregate planned stop-risk budget: 25 account-currency units.
- If the budget were allocated equally to the two models, each allocation would be 12.50 units.
- Two independent allocations of 0.25% each would instead amount to 50 units of planned initial stop risk.
These are arithmetic examples, not backtest results or recommended account sizes. Actual risk depends on the permitted volume, stop distance, contract specifications and execution. The total risk target is not a guaranteed loss ceiling.
3. Why volatility and minimum lot size matter
ATR adapts the protective stop distance to the observed range of price movement. When volatility expands, the stop can become wider. Keeping the nominal risk target unchanged generally requires reducing position size.
The EA calculates volume from equity and stop distance, rounds it down to the broker's permitted volume step, and skips an entry if the risk budget cannot support the minimum tradable volume. It also checks margin, volume limits, session availability and stop levels before submitting entries.
This is especially relevant for gold during volatile periods. A small account with a conservative risk target may produce very few trades, or none at all. Increasing the risk setting solely to force a higher trade count is not a sound way to evaluate a strategy.
4. Initial setup in MetaTrader 5
- Use the Strategy Tester first, with the intended broker's XAUUSD symbol and sufficient H1 and D1 history.
- Start with H1 as the displayed timeframe. The H1 and D1 calculations are internal, so the chart timeframe does not determine those calculations.
- Choose the operating mode and review InpTotalRiskPct and InpWeightA. Keep the risk assumptions consistent when comparing modes.
- Set a unique InpMagicBase and verify the broker's server-time rollover schedule, including InpNoEntryHour, InpResumeHour, InpRolloverHour and InpRolloverMinute.
- Check the optional InpMaxSpreadATR filter, permitted deviation and close-retry interval. Review the status display and Journal for rejected or skipped trades.
The rollover filter deserves particular attention because broker server hours, spread behavior and the underlying trading session are not interchangeable. A configuration that works on one broker may require adjustment on another.
5. What should be measured in a meaningful backtest?
Rather than optimizing all parameters at once, I would first compare Model A, Model B and the combined configuration over the same dates, with consistent initial equity and cost assumptions. Then I would evaluate the candidate settings on periods not used for selection.
- Net profit factor after recorded commission and swap, with any additional cost assumptions disclosed separately.
- Trade frequency, maximum equity drawdown and the distribution of losing trades.
- Simultaneous exposure when both models are active, including whether one model contributes information beyond the other.
- Skipped entries caused by minimum volume, spread, session restrictions or insufficient margin.
- Sensitivity to broker specifications, price history, execution delays and wider spreads.
Modeling quality matters, but a high-quality historical test is still not a forward result. A credible evaluation would report both the favorable and unfavorable periods rather than selecting only the most attractive equity curve.
6. What this EA is not
Despite the name, Gold Regime Portfolio is not a diversified multi-asset or hedged portfolio. Both models are long-only and can be correlated. There is no martingale, grid trading or external DLL dependency. These design choices do not by themselves establish an edge.
Gaps, slippage, spread changes, swap and execution conditions can cause actual losses to exceed the planned stop-risk target. A prolonged decline in gold can also be challenging for a long-only strategy. The purpose of the risk architecture is to make the planned exposure explicit, not to eliminate market risk.
A research-first approach
The useful question is whether combining two different definitions of a trend offers a measurable improvement over either model alone when evaluated with realistic costs and comparable risk. More entry signals are not automatically better, and neither is a higher historical profit factor achieved by excessively filtering trades.
I would be interested in hearing how other MQL5 developers evaluate overlapping strategies on the same instrument. Do you compare them independently first, or measure their contribution directly at portfolio level?
Disclosure: Gold Regime Portfolio is my own EA implementation. The examples above describe its design and illustrative risk calculations, not verified trading returns. Automated trading involves risk, and historical tests cannot guarantee future results.


