Donchian Gold EA
- Эксперты
-
Minh Truong Pham
Hello, my name is Pham and I am a programmer and trader! At here, I create amazing forex indicators and expert advisors for Metatrader.
I will try:
+ Provide best tools base on my 5 years experience as a trader and 10 years as a programmer. - Версия: 3.30
- Обновлено: 3 сентября 2026
- Активации: 20
A small gold trend edge, tested the hard way and published at its real size.
Read this part first
The earlier version of this page showed +221% and a profit factor of 2.18. Those numbers are wrong and I'm taking them down.
That simulation ran a flat 0.1 lot on $10,000. Every stop-out in it lost $403.77, which is 4.04% of the account, while the page claimed 0.5%. Scaled to a real 0.5%, the same trade list gives about +27%. I found it auditing my own research, not because a buyer complained, so I rebuilt everything: 11.5 years instead of 2.7, real spread, real swap, sizing that is what it says. Anyone who already bought gets the corrected version free.
What it does
It trades gold on a higher-timeframe channel breakout. It waits for the market to commit, takes one position, then hands control to a trailing stop calibrated to current volatility rather than a fixed pip count. A wide take-profit sits behind that as a ceiling, but the trail closes almost everything.
It trades both ways. Gold fell through 2022 and climbed through 2025, and a long-only system would have sat out half the sample. One position at a time, no grid, no averaging.
What it makes
XAUUSD, 2015 to 2026, 549 trades, roughly 48 a year. Spread modelled at 0.25 plus real overnight swap, which on gold longs costs more than the spread does.
| Risk per trade | Profit factor | Max equity DD | Return per year |
|---|---|---|---|
| 0.5% | 1.31 | 4.20% | +1.61% |
| 1.0% | 1.27 | 8.24% | +2.87% |
| 2.0% | 1.28 | 16.47% | +6.21% |
Win rate 45.7%. About 54% of months finish green, and 9 of the 12 calendar years were profitable.
Those returns are small and I'd rather you see them now than after you buy. This won't double an account. What it has instead is evidence that the edge is real, which is worth more than a flattering curve.
How I know it isn't curve-fitted
Any strategy can be tuned until the backtest looks good. Three tests, hardest first.
Walk-forward
I picked the settings using 2015 to 2020 only, then measured them on 2021 to 2026, a stretch the choice never saw:
Default preset 2015-2020 +0.0732R -> 2021-2026 +0.0707R Looser variant 2015-2020 +0.2507R -> 2021-2026 +0.2346R 41 configurations tested. 41 positive in the first period. 41 still positive in the second.
Curve-fitted settings fall apart when you do this. None of these did.
The same test showed one more thing worth telling you: backtest ranking does not predict future ranking. The correlation between the two periods is +0.08, which is nothing. More parameter hunting would only produce prettier backtests, so I stopped.
Four separate market periods
A single long backtest hides everything, so I cut the history into four disjoint stretches and required a positive result in each:
| Period | Market character | Avg R per trade | |
|---|---|---|---|
| 2015–2017 | Post-taper drift, low volatility | +0.140 | OK |
| 2018–2020 | Trade war, then COVID | +0.022 | OK, barely |
| 2021–Sep 2023 | Range-bound, rate hikes | +0.034 | OK |
| Oct 2023–Jun 2026 | The big gold run | +0.116 | OK |
Pooled: +0.0776R per trade across 547 trades, t = 2.32, 95% confidence interval +0.012 to +0.143.
That 2018 to 2020 number is honest and it's ugly. Three years of essentially standing still. Buy this in January 2018 and you'd have spent three years wondering why.
Rebuilt in the Strategy Tester
Python research is easy to fool, so I ran the compiled EA against live broker history, 2022-03 to 2026-07, $10,000 at 1:500: 195 trades, profit factor 1.403, maximum equity drawdown 2.43%. Different data, different engine, same conclusion.
Two presets, and the choice is real
The EA ships with two presets. They differ in one thing: how much room the exit gives a trade, and only two inputs change between them. You switch by typing two numbers, there are no files to load.
| Balanced (default) | Trend rider | |
|---|---|---|
| InpTrailActivate | 0.5 | 2.0 |
| InpTrailMult | 1.5 | 2.5 |
| Avg R per trade | +0.078 | +0.123 |
| Max drawdown, 0.5% risk | 4.2% | 8.8% |
| Max drawdown, 2% risk | 16.5% | 38.5% |
| Return per year, 2% risk | 6.21% | 6.63% |
| Periods positive | 4 of 4 | 3 of 4 |
Trend rider earns more per trade and rides further. It also loses money in ranges: through 2021 to September 2023 it averages -0.123R a trade while the default makes +0.034R.
I looked for a setting between the two. Thirty-six combinations, only two stayed positive across all four periods, and neither beat the default on return against drawdown. This isn't a dial with a better spot on it, it's a fork.
Default for the flatter curve. Trend rider if you believe gold keeps trending and can sit through a range. Read the 2% row first.
Gold only, and I checked
I ran the same logic on EURUSD, GBPUSD, USDCAD, the dollar index, S&P 500, Nasdaq 100 and Bitcoin. The edge showed up on none of them, and four came out negative.
So don't buy this expecting a portfolio EA. It works on gold, and I'd rather say so now than let you find out in month three.
How much capital you need
Gold is expensive in small size right now. With gold near 4400 and H4 volatility around $40, the minimum 0.01 lot already risks about $100 on one trade.
| Workable | Comfortable | |
|---|---|---|
| At 0.5% risk | $10,000 | $15,000+ |
| At 1.0% risk | $5,000 | $8,000+ |
| At 2.0% risk | $2,500 | $4,000+ |
Below that, the minimum lot forces more risk on you than you asked for. The EA won't let that happen quietly: it prints the equity you need when you attach it, and skips any trade where the smallest position would risk more than twice your chosen percentage. A cent account sidesteps this entirely, since the contract there is a hundredth the size.
Broker and account type
Best: Raw / ECN / Pro. Gold spread under 30 cents. The backtest assumes 25.
Fine: Standard. Spread up to about 50 cents barely registers, because stops are sized in volatility rather than pips. A 25-cent spread against a $100 stop is a quarter of one percent of the risk.
Avoid: brokers whose gold spread routinely passes $1, and anything with frequent requotes.
But swap matters more than spread here. Long gold carries a real overnight cost and this EA holds trades for days. It's in every number above.
Safety
- Stop loss from the moment the order opens, sized from live volatility. No virtual stops.
- No martingale, no grid, no averaging down. Ever.
- One position at a time, with a cooldown after each close so it can't chain trades through chop.
- Spread filter, and it logs how many signals it rejected.
- Refuses to trade rather than quietly oversizing a small account.
- Recovers its full state after a VPS reboot, trailing distance and entry volatility included.
- Pre-trade checks for margin, volume limits, stops level and freeze level.
- No DLL, no web requests, nothing leaves your terminal.
What to expect
Roughly four trades a month. Some months none.
Losing months come in runs. The longest flat stretch was three years, and most of the profit came from a handful of strong months. If a red quarter makes you switch an EA off, this one will frustrate you.
Win rate is under half. It makes money because winners run further than losers, not because it's right often.
There's an optional pyramiding mode, off by default. A buyer asked for it, I built it, and it lost money against the plain version. He pushed back and was half right: stacked on the trailing stop the ladder never gets room, but with the trail off it does earn in R. It still ends with less money at the same risk, and it turns the one bad period from -0.26R a trade into -0.81R. Full numbers are in the file header.
Past performance does not guarantee future results. Demo it for a month before committing money.
Quick setup
- Attach to a XAUUSD H4 chart. Not M5, not M15. Trailing and the cooldown follow the chart timeframe, and faster charts trail too tightly.
- Choose your preset. Balanced is the default and needs no changes. For Trend rider, set InpTrailActivate to 2.0 and InpTrailMult to 2.5. Nothing else differs between the two.
- Set InpRiskPct. Start at 0.5.
- Turn on Allow Algo Trading.
- Check the Experts tab. It prints the minimum equity your risk setting needs at current volatility. If it warns you there, fix that before going live.
Use a VPS. If the terminal is offline when a signal fires, the trade is gone.
Main settings
| Parameter | Default | What it does |
|---|---|---|
| Risk per trade (%) | 0.5 | Equity risked per trade |
| Fixed lot | 0.0 | Above zero overrides risk sizing |
| Max hold time | 0 | Off. Timing trades out measured worse everywhere |
| Initial stop | 2.5x | Stop distance in volatility units |
| InpTrailActivate | 0.5 | Profit in volatility units before the trail engages. Set 2.0 for Trend rider |
| InpTrailMult | 1.5 | How far the stop follows, in volatility units. Set 2.5 for Trend rider |
| Max spread | 500 pts | Signals skipped above this, 0 disables |
| Max risk multiple | 2.0 | Skip if the minimum lot exceeds this multiple of your risk |
| Pyramiding | false | Optional, see above |
| Magic number | 251004 | Change if you run two EAs on gold |
Updates and support
Every update goes through the full backtest suite before it ships, and I publish the numbers when they change. Buyers get all updates free, including the correction that produced this page.
Message me with your account size and broker and I'll tell you which preset and risk setting fit, or whether you're better off waiting until the account is larger.
