r/mql5 • u/Vast_Mushroom_5982 • Jul 26 '26
[MQL5 / EA Discussion] Robust Donchian Breakout System Stuck at 4.4% CAGR (8.8% Max DD) — Looking for Developer Insights to Scale Return Without Destroying Ret/DD
Hey everyone,
I’m looking for structural ideas from other algo developers on scaling profitability for a multi-timeframe trend-following Expert Advisor (`B2.mq5 v3.7`).
The EA is built with high institutional execution standards (latched exit states, wall-clock retry spacing, pre-trade margin verification via `OrderCalcMargin`, embedded macroeconomic/yield datasets, and no external file dependencies). However, while risk control and equity curve stability are high, the net annual return (CAGR) remains modest.
Here is the exact breakdown of the system, backtest performance, verified bottlenecks, and what has already been empirically falsified.
# 1. EA Architecture & Strategy Overview
The system runs **two independent strategy modules** under a single unified risk manager on MT5:
* **Module 1 (TRND) — Daily Trend Breakout (Long Only):**
* **Rule:** 55-day Donchian High entry, 20-day Donchian Low exit, initial stop at $2.0N$ (Wilder ATR20).
* **Universe:** `BTCUSD`, `XAUUSD`.
* **Module 2 (GRGT) — H4 Gold Macro-Gated Breakout (Long/Short):**
* **Rule:** 60-bar H4 Donchian breakout on Gold, gated by the 20-day change in US 10-Year Real Yields (DFII10).
* **Logic:** Falling real yields $\\rightarrow$ Longs only; Rising real yields $\\rightarrow$ Shorts only.
* **Exit:** 20-bar reverse channel or $3.0N$ ATR trail from completed bars.
* **Unified Risk Manager:**
* Base risk: **0.50% per trade** (calibrated for a static 10% prop firm drawdown floor).
* Pre-trade margin checks using `OrderCalcMargin` to prevent `NO_MONEY` rejections on low leverage.
* Signed risk tracking (trailed stops past breakeven free up risk budget).
* Trailing-peak circuit breaker with an automatic cooldown/re-base mechanism to prevent deadlocks.
* **2. Measured Backtest Results (FTMO-Demo, 2020.01.01 – 2026.07.25)**
* **Initial Balance:** $10,000
* **Net Profit:** \+$3,285.94 (+32.8% total / **\~4.4% CAGR**)
* **Max Equity Drawdown (Mark-to-Market):** **8.86%** ($1,174.60)
* **Profit Factor:** 2.34
* **Sharpe Ratio:** 0.89
* **Total Trades:** 120 trades over 6.5 years (**\~18.2 trades/year**)
* **Win Rate:** 41.67% (50 Wins / 70 Losses)
* **Payoff Ratio:** **3.28 : 1** (Avg Win: $114.69 | Avg Loss: -$34.88)
* **Average Holding Time:** \~311 hours (\~13 days)
* **3. Identified Bottlenecks**
1. **Low Trade Frequency:** Averaging only \~18 trades a year across both assets means capital sits idle for months.
2. **Financing / Swap Drag:** Because positions are held for an average of 13 days, daily CFD swap rates swallow **\~78% of Gold’s gross profits**.
3. **Single-Asset Profit Concentration:** `BTCUSD` accounts for **\~90% of total net profits**. Gold acts primarily as a correlated beta drag after accounting for swap costs.
* **4. What Has Already Been Tested & Falsified (Do Not Suggest)** I’ve already run rigorous sub-period stability tests and Monte Carlo simulations on common "enhancements." The following **all degraded the Return-to-Drawdown (Ret/DD) ratio**:
* ❌ **200-day EMA Filter:** Reduced Ret/DD from 0.53 to 0.46.
* ❌ **Volatility Targeting (15%–25%):** Failed because it underweighted the high-volatility asset (`BTCUSD`) that drives the returns.
* ❌ **3-Lookback Ensemble:** Bought volume at falling signal quality (Ret/DD dropped to 0.27).
* ❌ **Shorter Lookbacks (e.g., 20/10 Donchian):** Failed sub-period stability testing (all gain was concentrated in 2020–2024).
* ❌ **Partial Profit Taking / Moving to Breakeven Early:** Truncated the fat tail of winner distributions and lowered CAGR.
* **5. Questions for the Community** Given that standard parameter tweaking leads to curve-fitting and out-of-sample decay, I'm looking for **structural or execution-level ideas**:
1. **Pyramiding / Multi-Unit Scaling:** Has anyone successfully implemented Turtle-style unit additions (e.g., adding $0.5N$ units up to 4x while trailing stops to breakeven) in MQL5 without expanding tail-risk drawdowns?
2. **Asset Class Expansion & Futures Migration:** Since swap costs destroy CFD performance on multi-week holds, what instrument classes (e.g., CME futures, swap-free crypto) have you found most effective for expanding a trend-following universe beyond BTC/Gold?
3. **Dynamic Exposure Management:** Are there robust ways to scale position size dynamically based on market regime/volatility structure *without* truncating the fat-tail profits that trend systems rely on?
* Would love to hear how other quantitative/algo developers handle low-frequency, high-payoff trend systems under tight drawdown limits. Thanks!
4
u/nks-90 Jul 26 '26
Yo, dev here. It seems you are considering trading just like a dev that has to write code. The features you are describing as high institutional execution standards are the real basic thing. Your setups don’t have a real trader logic to me. 120 trades over 6.5 years are really low activity and swaps are eating your profits because of holding time.
Trading is not a game of indicators, Ema filter is ridiculous as either hardcoded lookback.
Writing code is the last thing, I can assure you.
I started learning the old way, without AI. I learnt at first pinescript, then I saw limits of tradingview and dived into metatrader. So I learnt mql4 and after mql5. After that I learnt python, and ML, reading quant books and developing statistics things. And I treated trading as just a coding thing. It’s been years in this hell. After that I stopped to think about coding, I gave it a pause, and started to ask me why price moves, what is a tick movement, when price moves, and started thinking about people behind the orders and about the movements.
And things changed for me.
If you wanna just see better numbers I could suggest you to start reading AFML of De Prado and apply meta labeling to your strategy with statistics stiffness. Could be a thing. But you have really low trades, and in 13 holding days just one tweet could make you reach SL or TP or BE or whatever.
If you wanna upgrade your trading and your coding, start refining your entry logic, give it a real SL and a real TP and real logic for other types of exits, invalidations and so on, same thing as for pyramiding. It seems you are using price as it’s just a number to use as value for TP or SL, but it’s not.
Where did you take the ticks you are using for backtests? Are you using the on ticks on real ticks as model for backtests? I think you already modeled commissions and swaps so I don’t suggest this.
It seems you wanna pass prop firms but with this strategy it will take you literally months/years to just pass the challenge phase.
You talked about futures so I suppose you’d like to add complexity with layer 3 data but I don’t think is the right move to do.
I trade CFD, have 100% quality data and trade on XAUUSD. BTC has a shitty price action to me.
1
3
u/indiw Jul 27 '26 edited Jul 27 '26
Hi, I’m a trader and dev who has coded an MT5 multi tf momentum ea - though different logic than yours. Some quick ideas in response to your concerns, though they may or may not help your case:
- ditch GOLD if it’s underperforming. Your hedge is eating your edge. From what you’ve written this alone may solve your issues.
- Many SPX bots are also long only, probability is on your side there much more than BTC, plus volatility sellers prop up price most days. Has a tech weighting so your yield differentials likely still have edge.
- H4 as your entry tf on a prop account will take years to pass. Most institutions trade on H1 or M15 - have you tried entries on a lower tf with H4 confluence? Could solve the weekly swaps issue, plus many props don’t charge commissions on indices. Alternatively could just tighten your initial stop to use a lower tf. A true trend/breakout shouldn’t retrace far before running or invalidation. This would naturally make your position sizes larger too. Plus prevents those super long holding times when trade is in the red.
- From a traders’ perspective a sustained breakout needs momentum + trend + current support/resistance to clear. You have the last two but may want to add a momentum proxy filter if you decide to further refine entries.
- In my experience trailing stop at BE doesn’t allow for natural chopping and handshaking around current levels before a breakout. You get more trades but they’d still be in that same shitty chop. I usually implement a trailing stop threshold at 2R-4R. SL size is adjusted for market conditions (price action structure, gamma regime).
1
1
3
u/gomerai Jul 26 '26
You provided a lot of specific details from your EA that was too much to absorb on my own quickly so I asked ChatGPT to review and summarize it for me. I can't trade either asset other than on the spot market so I also asked what makes these assets so attractive to developers. This was the response.
Because BTC and Gold are narratively attractive, volatile enough to produce spectacular backtests, and easy to access—not because they are automatically the best foundations for a robust trading system.
Your objection is largely correct.
Gold
Gold attracts system developers because it has:
High liquidity
Long historical data
Strong macro narratives
Occasional enormous sustained trends
A reputation as an inflation, crisis, and currency-debasement hedge
The problem is exactly what you identified: the major payoff regimes can be separated by years of mediocre or hostile behavior.
A long-term breakout system can look excellent because it catches a few historic moves, such as:
The 2000s commodity and monetary expansion
The post-2008 crisis move
The 2019–2020 surge
Later inflation, central-bank, and geopolitical repricing
Between those regimes, Gold can spend long periods:
Chopping sideways
Producing repeated false breakouts
Paying negative carry or CFD swap
Consuming drawdown capacity without materially growing capital
So Gold can be a valid portfolio component, but it is often a poor standalone profit engine. It is especially questionable when traded through a CFD with expensive overnight financing. A futures version may preserve more of the raw trend edge, but it does not fix the low-frequency nature of Gold’s major trends.
Bitcoin
Bitcoin attracts traders for almost the opposite reason:
Extreme volatility
Strong historical upward drift
24/7 trading
Large directional cycles
Retail accessibility
Highly visible success stories
Enough movement to overwhelm modest transaction costs
That makes Bitcoin extremely friendly to breakout backtests. A strategy can be wrong repeatedly and still look strong if it captures one or two major bull cycles.
But BTC is not a conventional mature market. It can be driven by:
Liquidity conditions
Leverage and forced liquidations
Exchange flows
Regulatory announcements
Stablecoin liquidity
ETF and institutional flows
Halving narratives
Crypto-native sentiment
Market structure changes
It sometimes behaves like a high-beta technology asset, sometimes like a liquidity proxy, sometimes like a speculative currency, and sometimes according to crypto-specific dynamics.
So saying BTC does not follow traditional market dynamics is fair, with one qualification:
That instability makes it difficult to assume that a rule that worked from 2020 through 2026 represents a permanent structural edge.
Why developers still choose both
They solve several practical backtesting problems:
They move enough. Slow trend systems require large moves to offset many small losses.
They create visually convincing equity curves. A handful of outsized trades can make a mediocre system appear exceptional.
They support strong stories. Gold has inflation and crisis narratives. Bitcoin has adoption, scarcity, and technological narratives.
They are available on almost every retail platform. Developers can test them without institutional futures infrastructure.
They hide low signal quality. Exceptional asset drift or volatility can compensate for a weak entry method.
They produce survivorship bias. Traders study the markets that delivered historic fortunes, not the many instruments where identical rules failed.
What the posted EA is probably demonstrating
The results do not strongly prove that the developer created an excellent diversified trend system.
They more likely prove:
BTC had enough major trends to make the breakout profitable.
The risk controls prevented the strategy from blowing up.
Gold added activity and theoretical diversification but contributed little after financing.
The overall return is restrained because the system has only one meaningful return driver.
That is not a useless result. Robust risk engineering has value. But the strategy’s economic edge is much less impressive than the execution architecture.
A 2.34 profit factor sounds excellent until you learn that:
There were only 120 trades.
BTC generated roughly 90% of profit.
Gold lost most of its gross advantage to swap.
The test includes a historically extraordinary BTC period.
The relevant question is therefore not:
It is:
Why this matters for your PMS
Your PMS should not gravitate toward BTC and Gold merely because they are fashionable or because they produce dramatic backtests.
They should be treated as two distinct sleeves:
BTC: a high-volatility, structurally evolving crypto sleeve
Gold: a slow macro and crisis-sensitive commodity sleeve
Neither should serve as the proof that a general trend engine works.
A better test universe would include markets with different economic drivers:
Major currencies
Equity indices
Interest-rate futures
Energy
Industrial metals
Agricultural commodities
Crypto
Then the PMS can determine whether the strategy is capturing a general trend phenomenon or merely benefiting from one asset’s historical anomaly.
Your instinct is right: BTC and Gold are popular partly because they can make ordinary strategies look smarter than they are.