Buys when the 12-period EMA crosses above the 21-period EMA and sells short when it crosses below. Each cross reverses any open position, so the system stays in the market after its first signal.
Best run of 11. USD/JPY, Daily, spread 1, from run pf:2026-10-12-USDJPY-D.tsv:39.
| Period | Up to 2026-10-12 |
| Instrument | USD/JPY, Daily |
| Spread | 1 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-12 |
Every run
| Market | Timeframe | PF | Trades | Win % | Net | Max DD |
|---|---|---|---|---|---|---|
| USD/JPYBest run | Daily | 1.59 | 503 | 33.40 | 3,435,460 USD | -433,100 |
| Gold | Daily | 1.55 | 517 | 31.72 | 3,460 EUR | -809 |
| USD/JPY | 1 hour | n/a | 5,209 | 30.04 | 1,051,280 USD | -298,730 |
| USD/JPY | 30 min | n/a | 7,477 | 29.06 | 468,660 USD | -258,680 |
| EUR/USD | Daily | n/a | 457 | 35.23 | 178,398 USD | -48,505 |
| Nikkei 225 | Daily | n/a | 432 | 31.02 | 29,614 USD | -21,264 |
| Nasdaq 100 | Daily | n/a | 424 | 29.95 | 15,714 EUR | -5,664 |
| Brent Crude | Daily | n/a | 197 | 30.46 | 15,137 EUR | -13,430 |
| US Crude Oil | 4 hours | n/a | 901 | 31.19 | 11,913 EUR | -6,177 |
| Gold | 4 hours | n/a | 1,138 | 31.72 | 3,310 EUR | -943 |
| Gold | 1 hour | n/a | 4,542 | 28.60 | 2,339 EUR | -1,249 |
Charts
Top 10 of 11 runs. The full list is in the table above.
Above 1.0 made money, below 1.0 lost money.
The code
// ============================================================== // EMA 12 21 Trend Crossover // ProRealAlgos Strategy Library | prorealalgos.com // Type: Trend // Direction: Long & short // Timeframe tested: Daily // ============================================================== DEFPARAM CumulateOrders = false emafast = ExponentialAverage[12](close) emaslow = ExponentialAverage[21](close)
16 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 11 market and timeframe combinations. The best run was USD/JPY, Daily, with a profit factor of 1.59 over 503 trades.
The best run had a maximum drawdown of 433,100 USD at the tested position size, against a net result of 3,435,460 USD.
It trades both long and short.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.