Buys when the trailing stop direction flips up as the average price crosses above its zero-lag linear regression line, and sells short on the mirror setup. Longs exit when the average price crosses below that line, and shorts exit when it crosses above.
Best run of 5. USD/JPY, 1 hour, spread 1, from run sweeps:2026-10-11-USDJPY-1h-opt.tsv:72.
| Period | Up to 2026-10-11 |
| Instrument | USD/JPY, 1 hour |
| 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-11 |
Every run
| Market | Timeframe | PF | Trades | Win % | Net | Max DD |
|---|---|---|---|---|---|---|
| USD/JPYBest run | 1 hour | n/a | 1,113 | 38.81 | 142,210 USD | -94,500 |
| Brent Crude | 4 hours | n/a | 224 | 43.75 | 3,726 EUR | -1,676 |
| Nasdaq 100 | 4 hours | n/a | 456 | 36.18 | 3,428 EUR | -3,315 |
| FTSE 100 | Daily | n/a | 160 | 40.62 | 2,198 EUR | -1,408 |
| GBP/USD | 4 hours | n/a | 481 | 43.04 | 2,091 USD | -1,404 |
Charts
The code
// ============================================================== // Zero Lag Trend Flip Cross // ProRealAlgos Strategy Library | prorealalgos.com // Type: Trend // Direction: Long & short // Timeframe tested: 1 hour // ============================================================== DEFPARAM CumulateOrders = false ONCE longstop = 0 ONCE shortstop = 0 ONCE dir = 1 ONCE tradeopen = 0 ONCE cache = 0 ha = (open + high + low + close) / 4 myAtr = 2 * AverageTrueRange[1](close) lsprev = longstop ssprev = shortstop
102 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 5 market and timeframe combinations. The best run by trade count was USD/JPY, 1 hour, with 1,113 trades.
The best run had a maximum drawdown of 94,500 USD at the tested position size, against a net result of 142,210 USD.
It trades both long and short.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.