It buys when the 5 EMA crosses above the 10 EMA in a bullish 5, 10, 20 EMA stack, with close above the 20 and 50 SMAs. Stop and target are set from the distance to the 20 EMA, with a 1.5 reward ratio.
Best run of 2. Gold, Daily, spread 0.6, from run sweeps:2026-10-11-GOLD-D-opt.tsv:23.
| Period | Up to 2026-10-11 |
| 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-11 |
Every run
| Market | Timeframe | PF | Trades | Win % | Net | Max DD |
|---|---|---|---|---|---|---|
| GoldBest run | Daily | n/a | 353 | 36.83 | 571 EUR | -287 |
| Silver | Daily | n/a | 329 | 31.31 | 6,671 USD | -5,518 |
Charts
The code
// ============================================================== // EMA Stack Crossover Trend // ProRealAlgos Strategy Library | prorealalgos.com // Type: Trend // Direction: Long & short // Timeframe tested: Daily // ============================================================== DEFPARAM CumulateOrders = false ONCE barsflat = 1000000 ONCE wason = 0 emafive = ExponentialAverage[5](close) ematen = ExponentialAverage[10](close) ematwenty = ExponentialAverage[20](close) smatwenty = Average[20](close) smafifty = Average[50](close) barsflat = barsflat + 1 IF wason = 1 AND NOT OnMarket THEN barsflat = 0 ENDIF
26 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 2 market and timeframe combinations. The best run by trade count was Gold, Daily, with 353 trades.
The best run had a maximum drawdown of 287 EUR at the tested position size, against a net result of 571 EUR.
It trades both long and short.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.