The strategy buys when close moves back above a lower band built on a 20-bar EMA, and sells short at the mirror upper band. Longs exit when close rises above the EMA or more than 20 bars have passed since the last buy signal.
Best run of 8. USD/JPY, 4 hours, spread 1, from run sweeps:2026-10-11-USDJPY-4h-opt.tsv:5.
| Period | Up to 2026-10-11 |
| Instrument | USD/JPY, 4 hours |
| 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-11 |
Every run
| Market | Timeframe | PF | Trades | Win % | Net | Max DD |
|---|---|---|---|---|---|---|
| USD/JPYBest run | 4 hours | n/a | 964 | 65.66 | 188,470 USD | -177,330 |
| Dow Jones | Daily | n/a | 377 | 68.97 | 12,907 EUR | -8,615 |
| Nasdaq 100 | 4 hours | n/a | 937 | 63.39 | 6,171 EUR | -3,036 |
| FTSE 100 | Daily | n/a | 291 | 68.04 | 5,166 EUR | -1,946 |
| Nasdaq 100 | Daily | n/a | 288 | 62.15 | 3,799 EUR | -3,305 |
| FTSE 100 | 4 hours | n/a | 818 | 67.48 | 2,885 EUR | -1,799 |
| S&P 500 | 4 hours | n/a | 933 | 66.88 | 2,514 EUR | -847 |
| S&P 500 | Daily | n/a | 397 | 70.28 | 1,689 EUR | -907 |
Charts
The code
// ============================================================== // EMA Band Reversion With Time Stop // ProRealAlgos Strategy Library | prorealalgos.com // Type: Mean reversion // Direction: Long & short // Timeframe tested: 4 hours // ============================================================== DEFPARAM CumulateOrders = false ONCE lastbuy = -1 ONCE lastshort = -1 basis = ExponentialAverage[20](close) sumsqr = 0 FOR myI = 0 TO 19 DO sumsqr = sumsqr + SQUARE(close[myI] - basis) NEXT dev = 2 * SQRT(sumsqr / 20) upper = basis + dev lower = basis - dev
27 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 8 market and timeframe combinations. The best run by trade count was USD/JPY, 4 hours, with 964 trades.
The best run had a maximum drawdown of 177,330 USD at the tested position size, against a net result of 188,470 USD.
It trades both long and short.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.