The strategy buys when close crosses above a downward trendline through two recent swing highs, while the close is above the 200-bar EMA. It sells short when close crosses below an upward trendline through two swing lows, while below that EMA.
Best run of 6. US Crude Oil, 4 hours, spread 3, from run pf:2026-10-12-CRUDE-4h.tsv:3.
| Period | Up to 2026-10-12 |
| Instrument | US Crude Oil, 4 hours |
| Spread | 3 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 |
|---|---|---|---|---|---|---|
| US Crude OilBest run | 4 hours | 1.73 | 115 | 43.48 | 5,295 EUR | -1,323 |
| Dow Jones | 1 hour | n/a | 203 | 41.38 | 6,863 EUR | -3,249 |
| Nasdaq 100 | Daily | n/a | 45 | 37.78 | 3,692 EUR | -1,553 |
| Brent Crude | 4 hours | n/a | 97 | 39.18 | 3,423 EUR | -1,615 |
| Gold | 4 hours | n/a | 180 | 37.78 | 593 EUR | -244 |
| Gold | Daily | n/a | 53 | 45.28 | 516 EUR | -184 |
Charts
The code
// ============================================================== // Pivot Trendline Breakout (long and short) 3 // ProRealAlgos Strategy Library | prorealalgos.com // Type: Breakout // Direction: Long & short // Timeframe tested: 4 hours // ============================================================== DEFPARAM CumulateOrders = false ONCE phone = 0 ONCE phonebar = -1000 ONCE phtwo = 0 ONCE phtwobar = -1000 ONCE plone = 0 ONCE plonebar = -1000 ONCE pltwo = 0 ONCE pltwobar = -1000 ONCE bully = 0 ONCE bullok = 0 ONCE beary = 0 ONCE bearok = 0 ema = ExponentialAverage[200](close)
56 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 US Crude Oil, 4 hours, with a profit factor of 1.73 over 115 trades.
The best run had a maximum drawdown of 1,323 EUR at the tested position size, against a net result of 5,295 EUR.
It trades both long and short.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.