Buys when price closes above the upper band of a 9-period EMA envelope displaced 13 bars, while the close stays above a 2 ATR(15) trailing line. Sells short on the mirror setup below the lower band, and exits when the trailing line is crossed.
Best run of 5. USD/JPY, Daily, spread 1, from run pf:2026-10-12-USDJPY-D.tsv:48.
| 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.48 | 607 | 40.53 | 3,332,360 USD | -368,860 |
| EUR/USD | Daily | n/a | 590 | 39.83 | 100,528 USD | -60,117 |
| DAX 40 | 1 hour | n/a | 4,204 | 35.94 | 9,836 EUR | -6,399 |
| DAX 40 | 30 min | n/a | 6,590 | 35.96 | 5,544 EUR | -4,850 |
| Gold | 1 hour | n/a | 4,138 | 35.94 | 1,122 EUR | -1,083 |
Charts
The code
// ============================================================== // Displaced Envelope With ATR Trail // ProRealAlgos Strategy Library | prorealalgos.com // Type: Trend // Direction: Long & short // Timeframe tested: Daily // ============================================================== DEFPARAM CumulateOrders = false ONCE ts = 0 ONCE pos = 0 ema = ExponentialAverage[9](close) top = ema[13] * (100 + 0.5) / 100 bott = ema[13] * (100 - 0.5) / 100 myLoss = 2 * AverageTrueRange[15](close) prev = ts
39 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 5 market and timeframe combinations. The best run was USD/JPY, Daily, with a profit factor of 1.48 over 607 trades.
The best run had a maximum drawdown of 368,860 USD at the tested position size, against a net result of 3,332,360 USD.
It trades both long and short.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.