Join waitlist
Strategies / Trend / Displaced Envelope With ATR Trail

Displaced Envelope With ATR Trail

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.

TrendLong & shortSwingUSD/JPYDaily
1.48Profit factor
3,332,360Net profit USD
40.53%Win rate
607Trades
-368,860Max drawdown
5,490Avg trade

Best run of 5. USD/JPY, Daily, spread 1, from run pf:2026-10-12-USDJPY-D.tsv:48.

Entry rules, long

  1. The close is above the ATR trailing line, which sits 2 times ATR(15) below the close and ratchets up.

Entry rules, short

  1. The close is below the ATR trailing line.

Exit rules

  1. A short closes when the close is not below the ATR trailing line while the state is down.

Test conditions

PeriodUp to 2026-10-12
InstrumentUSD/JPY, Daily
Spread1 points
Starting capital1,000,000
CostsSpread only. Commissions and overnight financing are not included.
BarsUp to 200,000 bars, fewer where the instrument has less history
Last tested2026-10-12

Every run

Markets and timeframes tested

MarketTimeframePFTradesWin %NetMax DD
USD/JPYBest runDaily1.48 60740.533,332,360 USD-368,860
EUR/USDDailyn/a 59039.83100,528 USD-60,117
DAX 401 hourn/a 4,20435.949,836 EUR-6,399
DAX 4030 minn/a 6,59035.965,544 EUR-4,850
Gold1 hourn/a 4,13835.941,122 EUR-1,083

Charts

Results by run

Net profitMax drawdown

The code

ProBuilder code, as tested

// ==============================================================
// 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

How to load it

  1. Copy the code with the copy button on the code block.
  2. In ProRealTime, open a chart of the instrument and timeframe you want to test, then open ProOrder > New trading system and choose "Create with programming".
  3. Paste the code, give the system a name and save it.
  4. Click "Backtest", set your own spread and position size, and run it before you consider trading it live.

Indicators used

EMAATR
Read this firstKnown weaknesses2 points
  • The code sets no stop loss, so a losing trade stays open until an exit signal arrives.
  • Results include the spread only. Commissions and overnight financing are not included.

Questions

About this strategy

Can I run Displaced Envelope With ATR Trail in ProOrder?

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.

Which markets was it tested on?

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.

How large was the drawdown?

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.

Does it trade long, short or both?

It trades both long and short.

Related

Strategies like this one

Reversal Pattern With Chaikin Volatility

Uses the same indicator.

2.26 PF · 6,872 trades

Trend Surfer

Best run on the same market, USD/JPY.

1.04 PF · 10,813 trades

Parabolic SAR Upside Crossover

Also a trend strategy.

1.48 PF · 550 trades

Want strategies that are already part of a live portfolio? Join the ProRealAlgos waitlist.

The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.

Past backtest results do not guarantee future results. This is not financial advice. Curated and maintained by ProRealAlgos. ProRealTime™ is a trademark of ProRealTime SAS. prorealalgos.comStatsDocs