Join waitlist
Strategies / Breakout / 20-Bar Breakout With ATR Stop

20-Bar Breakout With ATR Stop

The strategy buys when the close breaks above the highest high of the prior 20 bars and sells short when it breaks below the lowest low. It exits on a 10-bar break against the position.

BreakoutLong & shortSwingUSD/JPYDaily
10.06Profit factor
2,698,920Net profit USD
2.79%Win rate
1,434Trades
-150,480Max drawdown
1,882Avg trade

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

Entry rules, long

  1. Buys one contract at market when not already long, after bar 25.

Entry rules, short

  1. Sells short one contract at market when not already short, after bar 25.

Exit rules

  1. A stop loss is set 2 times ATR(20) from the entry price, measured from the fill.
  2. A short is covered at market when the close rises above the highest high of the prior 10 bars.

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 runDaily10.06 1,4342.792,698,920 USD-150,480
Nikkei 225Dailyn/a 39836.1824,193 USD-19,984
Brent CrudeDailyn/a 17136.2613,840 EUR-9,427
US Crude OilDailyn/a 37335.3911,150 EUR-7,669
GoldDailyn/a 44734.681,866 EUR-809
Gold4 hoursn/a 97634.021,140 EUR-981

Charts

Results by run

Net profitMax drawdown

The code

ProBuilder code, as tested

// ==============================================================
// 20-Bar Breakout With ATR Stop
// ProRealAlgos Strategy Library  |  prorealalgos.com
// Type: Breakout
// Direction: Long & short
// Timeframe tested: Daily
// ==============================================================

DEFPARAM CumulateOrders = false

hh = highest[20](high)
ll = lowest[20](low)
xl = lowest[10](low)
xh = highest[10](high)
myAtr = AverageTrueRange[20](close)

22 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

ATRDonchian Channel
Read this firstKnown weaknesses2 points
  • Results include the spread only. Commissions and overnight financing are not included.
  • The code is published as it was backtested and has not been compiled again since.

Questions

About this strategy

Can I run 20-Bar Breakout With ATR Stop 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 6 market and timeframe combinations. The best run was USD/JPY, Daily, with a profit factor of 10.06 over 1,434 trades.

How large was the drawdown?

The best run had a maximum drawdown of 150,480 USD at the tested position size, against a net result of 2,698,920 USD.

Does it trade long, short or both?

It trades both long and short.

Related

Strategies like this one

Turtle Trade

Uses the same indicator.

2.42 PF · 6,324 trades

Trend Surfer

Best run on the same market, USD/JPY.

1.04 PF · 10,813 trades

Channel Break With SMA Trend

Also a breakout strategy.

8.83 PF · 933 trades

Put your name on the ProRealAlgos waitlist to trade a tested portfolio instead of single strategies.

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