The strategy buys on a bullish MACD crossover when +DI(14) is above -DI(14). It closes the long on a bearish MACD crossover with -DI(14) above +DI(14), or when the close falls below an ATR(20) volatility stop.
Best run of 36. Gold, Daily, spread 0.6, from run pf:2026-10-04-GOLD-D.tsv:3.
| Period | Up to 2026-10-04 |
| Instrument | Gold, Daily |
| Spread | 0.6 points |
| Starting capital | 1,000,000 |
| Costs | Spread only. Commissions and overnight financing are not included. |
| Bars | Up to 200,000 bars, fewer where the instrument has less history |
| Last tested | 2026-10-04 |
Every run
| Market | Timeframe | PF | Trades | Win % | Net | Max DD |
|---|---|---|---|---|---|---|
| GoldBest run | Daily | 3.02 | 144 | 38.19 | 3,651 EUR | -809 |
| S&P 500 | Daily | 2.30 | 169 | 40.83 | 3,765 EUR | -569 |
| Gold | 4 hours | 2.29 | 293 | 38.57 | 4,048 EUR | -568 |
| DAX 40 | Daily | 1.98 | 174 | 40.23 | 17,287 EUR | -3,850 |
| Gold | 3 min | 1.21 | 1,910 | 31.10 | 1,893 EUR | -431 |
| USD/JPY | 10 min | 1.18 | 2,024 | 33.65 | 469,740 USD | -112,480 |
| USD/JPY | 30 min | n/a | 1,882 | 33.90 | 570,100 USD | -207,530 |
| USD/JPY | 1 hour | n/a | 1,302 | 33.79 | 539,870 USD | -421,060 |
| EUR/USD | Daily | n/a | 138 | 32.61 | 53,416 USD | -39,280 |
| EUR/USD | 4 hours | n/a | 439 | 34.40 | 40,844 USD | -36,463 |
| Nikkei 225 | Daily | n/a | 122 | 34.43 | 31,510 USD | -15,442 |
| Silver | Daily | n/a | 131 | 24.43 | 24,322 USD | -19,961 |
| Nikkei 225 | 4 hours | n/a | 250 | 36.40 | 21,237 USD | -10,986 |
| Dow Jones | Daily | n/a | 164 | 42.68 | 19,860 EUR | -12,283 |
| Silver | 15 min | n/a | 1,986 | 29.61 | 17,833 USD | -9,757 |
| Nikkei 225 | 10 min | n/a | 1,927 | 32.12 | 16,924 USD | -13,284 |
| Dow Jones | 4 hours | n/a | 99 | 39.39 | 13,398 EUR | -3,595 |
| Nasdaq 100 | 4 hours | n/a | 327 | 47.71 | 13,001 EUR | -4,016 |
| Nasdaq 100 | 1 hour | n/a | 1,143 | 35.52 | 11,047 EUR | -2,809 |
| DAX 40 | 4 hours | n/a | 298 | 39.26 | 9,718 EUR | -3,777 |
| Dow Jones | 15 min | n/a | 1,660 | 32.65 | 9,075 EUR | -8,086 |
| Nasdaq 100 | 15 min | n/a | 1,911 | 35.01 | 8,581 EUR | -4,909 |
| Nasdaq 100 | Daily | n/a | 145 | 43.45 | 6,966 EUR | -6,348 |
| Brent Crude | Daily | n/a | 69 | 39.13 | 6,954 EUR | -6,411 |
| Nasdaq 100 | 30 min | n/a | 2,020 | 36.98 | 6,902 EUR | -4,213 |
| DAX 40 | 15 min | n/a | 1,969 | 31.89 | 6,033 EUR | -4,371 |
| Nasdaq 100 | 10 min | n/a | 1,958 | 33.55 | 5,869 EUR | -4,292 |
| Brent Crude | 1 hour | n/a | 621 | 36.71 | 5,190 EUR | -4,466 |
| Gold | 5 min | n/a | 1,872 | 33.28 | 2,300 EUR | -644 |
| Gold | 1 hour | n/a | 1,109 | 33.54 | 2,094 EUR | -1,059 |
| S&P 500 | 4 hours | n/a | 330 | 38.79 | 1,897 EUR | -772 |
| S&P 500 | 1 hour | n/a | 1,196 | 36.20 | 1,786 EUR | -787 |
| Gold | 30 min | n/a | 1,948 | 33.68 | 1,751 EUR | -1,275 |
| Gold | 15 min | n/a | 1,972 | 29.77 | 1,622 EUR | -871 |
| Gold | 10 min | n/a | 1,974 | 31.41 | 1,521 EUR | -839 |
| S&P 500 | 15 min | n/a | 1,965 | 33.03 | 1,446 EUR | -1,140 |
Charts
Top 10 of 36 runs. The full list is in the table above.
Above 1.0 made money, below 1.0 lost money.
The code
// ============================================================== // MACD Crossover Volatility Stop Filter // ProRealAlgos Strategy Library | prorealalgos.com // Type: Trend // Direction: Long only // Timeframe tested: Daily // ============================================================== DEFPARAM CumulateOrders = false ONCE vmax = 0 ONCE vmin = 0 ONCE vup = 1 ONCE vstop = 0 ONCE vinit = 0 macdl = MACDline[12,26,9](close) macds = ExponentialAverage[9](macdl) myDiplus = DIplus[14](close) myDiminus = DIminus[14](close) atrm = AverageTrueRange[20](close) * 2.0 IF vinit = 0 THEN vmax = close vmin = close vinit = 1 ENDIF vmax = MAX(vmax, close) vmin = MIN(vmin, close) prevup = vup IF prevup = 1 THEN vstop = MAX(vstop, vmax - atrm) ELSE vstop = MIN(vstop, vmin + atrm) ENDIF
29 more lines: the entry and exit rules.
Setup
Gold had no history beyond the standard run, so both runs used 13,000 bars.
| Bars available | 13,000 |
| Net, standard 200,000-bar run | 3,651.20 EUR |
| Net, long run | 3,651.20 EUR |
| Net on the older data alone | 0.00 EUR |
Questions
Yes. The code is ProBuilder and runs as an automated ProOrder system. Backtest it on your own account with your own spread and position size before trading it live.
It was tested on 36 market and timeframe combinations. The best run was Gold, Daily, with a profit factor of 3.02 over 144 trades.
The best run had a maximum drawdown of 809 EUR at the tested position size, against a net result of 3,651 EUR.
It only takes long trades.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.