Goes long when a 22-bar trailing stop line flips up and short when it flips down, each signal reversing the position. Exits come at a 5% loss on the close, a 20% gain on the high, or a 5-point giveback after a 10% peak.
Best run of 7. Gold, 4 hours, spread 0.6, from run sweeps:2026-10-07-GOLD-4h-opt.tsv:60.
| Period | Up to 2026-10-07 |
| Instrument | Gold, 4 hours |
| Spread | 0.6 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-10 |
Every run
| Market | Timeframe | PF | Trades | Win % | Net | Max DD |
|---|---|---|---|---|---|---|
| GoldBest run | 4 hours | n/a | 1,097 | 34.82 | 2,302 EUR | -1,287 |
| USD/JPY | Daily | n/a | 531 | 32.58 | 1,982,850 USD | -547,510 |
| EUR/USD | Daily | n/a | 473 | 35.94 | 114,085 USD | -83,265 |
| Nikkei 225 | Daily | n/a | 534 | 32.77 | 31,530 USD | -17,851 |
| GBP/USD | Daily | n/a | 534 | 35.39 | 14,011 USD | -8,268 |
| Nasdaq 100 | Daily | n/a | 516 | 28.68 | 6,402 EUR | -5,680 |
| Gold | Daily | n/a | 538 | 33.83 | 2,469 EUR | -1,269 |
Charts
The code
// ============================================================== // Trailing Stop Flip Reversal // ProRealAlgos Strategy Library | prorealalgos.com // Type: Trend // Direction: Long & short // Timeframe tested: 4 hours // ============================================================== DEFPARAM CumulateOrders = false ONCE longstop = 0 ONCE shortstop = 0 ONCE dir = 1 ONCE peak = 0 ONCE speak = 0 myAtr = 3 * AverageTrueRange[22](close) longraw = highest[22](close) - myAtr shortraw = lowest[22](close) + myAtr
64 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 7 market and timeframe combinations. The best run by trade count was Gold, 4 hours, with 1,097 trades.
The best run had a maximum drawdown of 1,286 EUR at the tested position size, against a net result of 2,302 EUR.
It trades both long and short.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.