The strategy buys during an uptrend when the 9, 21 and 50-period EMAs are stacked in order and the close sits 0 to 3% above the 9-period EMA. It exits when the close falls below the 21-period EMA, and uses no stop or target.
Best run of 1. US Crude Oil, 4 hours, spread 3, from run sweeps:2026-10-03-CRUDE-4h-opt.tsv:14.
| Period | Up to 2026-10-03 |
| Instrument | US Crude Oil, 4 hours |
| Spread | 3 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-03 |
Every run
| Market | Timeframe | PF | Trades | Win % | Net | Max DD |
|---|---|---|---|---|---|---|
| US Crude OilBest run | 4 hours | n/a | 2 | 50.00 | 1,067 EUR | -705 |
Charts
The code
// ============================================================== // EMA Stack Ride Long // ProRealAlgos Strategy Library | prorealalgos.com // Type: Trend // Direction: Long only // Timeframe tested: 4 hours // ============================================================== DEFPARAM CumulateOrders = false ONCE barsabove = 0 emafast = ExponentialAverage[9](close) emamid = ExponentialAverage[21](close) emaslow = ExponentialAverage[50](close)
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 one combination, US Crude Oil, 4 hours, with 2 trades.
The best run had a maximum drawdown of 705 EUR at the tested position size, against a net result of 1,067 EUR.
It only takes long trades.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.