Buys when the MACD histogram crosses above its own 9 period EMA and closes when it crosses back below. This long only strategy has no stop or target.
Best run of 12. Gold, 4 hours, spread 0.6, from run pf:2026-10-13-GOLD-4h.tsv:3.
| Period | Up to 2026-10-13 |
| Instrument | Gold, 4 hours |
| 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-13 |
Every run
| Market | Timeframe | PF | Trades | Win % | Net | Max DD |
|---|---|---|---|---|---|---|
| GoldBest run | 4 hours | 1.26 | 1,753 | 42.04 | 3,075 EUR | -657 |
| Dow Jones | Daily | n/a | 834 | 42.57 | 28,243 EUR | -7,278 |
| Silver | 4 hours | n/a | 1,763 | 39.42 | 25,425 USD | -14,635 |
| Nikkei 225 | 4 hours | n/a | 1,468 | 40.80 | 13,727 USD | -12,548 |
| Dow Jones | 4 hours | n/a | 589 | 43.46 | 12,340 EUR | -10,025 |
| DAX 40 | Daily | n/a | 869 | 41.89 | 10,942 EUR | -3,217 |
| DAX 40 | 4 hours | n/a | 1,734 | 42.16 | 10,424 EUR | -5,102 |
| Nasdaq 100 | 4 hours | n/a | 1,843 | 41.35 | 8,367 EUR | -4,835 |
| Nasdaq 100 | Daily | n/a | 685 | 40.73 | 6,442 EUR | -4,535 |
| Brent Crude | 4 hours | n/a | 1,011 | 41.25 | 6,065 EUR | -4,375 |
| S&P 500 | Daily | n/a | 884 | 41.06 | 2,484 EUR | -1,180 |
| Gold | Daily | n/a | 803 | 39.73 | 1,777 EUR | -1,519 |
Charts
Top 10 of 12 runs. The full list is in the table above.
The code
// ============================================================== // MACD Histogram Signal Crossover (long only) 3 // ProRealAlgos Strategy Library | prorealalgos.com // Type: Momentum // Direction: Long only // Timeframe tested: 4 hours // ============================================================== DEFPARAM CumulateOrders = false myMacd = ExponentialAverage[12](close) - ExponentialAverage[26](close) signal = ExponentialAverage[9](myMacd) macdas = myMacd - signal signalas = ExponentialAverage[9](macdas)
9 more lines: the entry and exit rules.
Setup
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 12 market and timeframe combinations. The best run was Gold, 4 hours, with a profit factor of 1.26 over 1,753 trades.
The best run had a maximum drawdown of 657 EUR at the tested position size, against a net result of 3,075 EUR.
It only takes long trades.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.