Join waitlist
Strategies / Trend / Trailing Stop Flip Reversal

Trailing Stop Flip Reversal

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.

TrendLong & shortSwingGold4 hours
n/aProfit factor
2,302Net profit EUR
34.82%Win rate
1,097Trades
-1,287Max drawdown
2.10Avg trade

Best run of 7. Gold, 4 hours, spread 0.6, from run sweeps:2026-10-07-GOLD-4h-opt.tsv:60.

Entry rules, long

  1. The stop line is the 22-bar highest close minus 3 times the 22-bar average true range, moving up only.

Entry rules, short

  1. The short stop line is the 22-bar lowest close plus 3 times the 22-bar average true range, moving down only.

Exit rules

  1. A long also closes when the high is more than 20% above the entry price.
  2. A long closes after the high has been more than 10% above entry and then falls back more than 5 percentage points.
  3. Short trades use the mirrored thresholds: close more than 5% above entry, low more than 20% below entry, or a similar 5-point giveback after 10%.
  4. An opposite direction flip closes the trade and reverses it.

Test conditions

PeriodUp to 2026-10-07
InstrumentGold, 4 hours
Spread0.6 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-10

Every run

Markets and timeframes tested

MarketTimeframePFTradesWin %NetMax DD
GoldBest run4 hoursn/a 1,09734.822,302 EUR-1,287
USD/JPYDailyn/a 53132.581,982,850 USD-547,510
EUR/USDDailyn/a 47335.94114,085 USD-83,265
Nikkei 225Dailyn/a 53432.7731,530 USD-17,851
GBP/USDDailyn/a 53435.3914,011 USD-8,268
Nasdaq 100Dailyn/a 51628.686,402 EUR-5,680
GoldDailyn/a 53833.832,469 EUR-1,269

Charts

Results by run

Net profitMax drawdown

The code

ProBuilder code, as tested

// ==============================================================
// 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

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

ATR
Read this firstKnown weaknesses3 points
  • No profit factor is available, because only sweep results exist for this strategy.
  • The maximum drawdown of 1,286 EUR is large next to the net profit of 2,302 EUR.
  • The code sets no stop loss, so a losing trade stays open until an exit signal arrives.

Questions

About this strategy

Can I run Trailing Stop Flip Reversal 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 7 market and timeframe combinations. The best run by trade count was Gold, 4 hours, with 1,097 trades.

How large was the drawdown?

The best run had a maximum drawdown of 1,286 EUR at the tested position size, against a net result of 2,302 EUR.

Does it trade long, short or both?

It trades both long and short.

Related

Strategies like this one

KDJ J Line Momentum Long

Uses the same indicator.

4.17 PF · 6,135 trades

CCI Breakout

Best run on the same market, Gold.

1.08 PF · 6,065 trades

ADX Filtered EMA Cross

Also a trend strategy.

1.15 PF · 607 trades

Get the full rules, the complete code and the ProRealAlgos portfolio as a member.

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