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.
Best run of 6. USD/JPY, Daily, spread 1, from run pf:2026-10-12-USDJPY-D.tsv:36.
| 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 | 10.06 | 1,434 | 2.79 | 2,698,920 USD | -150,480 |
| Nikkei 225 | Daily | n/a | 398 | 36.18 | 24,193 USD | -19,984 |
| Brent Crude | Daily | n/a | 171 | 36.26 | 13,840 EUR | -9,427 |
| US Crude Oil | Daily | n/a | 373 | 35.39 | 11,150 EUR | -7,669 |
| Gold | Daily | n/a | 447 | 34.68 | 1,866 EUR | -809 |
| Gold | 4 hours | n/a | 976 | 34.02 | 1,140 EUR | -981 |
Charts
The code
// ============================================================== // 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
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 6 market and timeframe combinations. The best run was USD/JPY, Daily, with a profit factor of 10.06 over 1,434 trades.
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.
It trades both long and short.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.