Join today
Strategies / Breakout / Trend Breakout

Trend Breakout

A fractal high starts a falling trend line, and a two-step break of that line arms a buy stop 0.3 ATR(7) above the recent high. Exits use an exponential band and RSI(2), closing longs once RSI is at 85 or higher and price is back below the upper band. Shorts mirror the logic.

BreakoutLong & shortSwingUSD/JPY4 hours
n/aProfit factor
161,440Net profit JPY
53.36%Win rate
819Trades
-93,910Max drawdown
197Avg trade

Best run of 8. USD/JPY, 4 hours, spread 1, from run sweeps:2026-09-17-USDJPY-4h-opt.tsv:2.

Entry rules, long

  1. A fractal high (a bar higher than the two bars on each side) starts a falling trend line
  2. Members only
  3. A buy stop is placed 0.3 ATR(7) above the highest high of the last 2 bars and re-placed each bar while the break holds

Entry rules, short

  1. A fractal low starts a rising trend line
  2. Members only
  3. A sell stop is placed 0.3 ATR(7) below the lowest low of the last 2 bars and re-placed each bar while the break holds

Exit rules

  1. No fixed stop loss or target
  2. A long exit is armed when price falls back inside the upper exponential band (34, 1.618 deviations) or makes a new 100-bar high or low
  3. Members only
  4. Shorts mirror this with the lower band and RSI(2) at 15 or lower

Test conditions

PeriodUp to 2026-09-17
InstrumentUSD/JPY, 4 hours
Spread1 points
Contracts1
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-09-17

Parameters

positionSize
Contracts per trade
1
fractalBars
Bars the centre of the 5-bar fractal must beat (structural, keep at 4)
4
breakoutBars
Bars used for the breakout high or low
2
atrPeriod
ATR length for the entry buffer
7
atrMultiplier
Entry buffer beyond the breakout level, in ATRs
0.3
bandPeriod
Length of the exponential log-price bands
34
seedPeriod
SMA length used to seed the bands on early bars
3
bandWidth
Band width in standard deviations
1.618
rsiPeriod
RSI length for the exit
2
overboughtLevel
RSI level a long exit needs
85
oversoldLevel
RSI level a short exit needs
15
lookbackPeriod
Window for the prior swing high and low
100

Every run

Markets and timeframes tested

MarketTimeframePFTradesWin %NetMax DD
USD/JPYBest run4 hoursn/a 81953.36161,440 JPY-93,910
USD/JPYDailyn/a 30059.00754,540 JPY-174,840
Nikkei 225Dailyn/a 26261.0720,201 USD-12,694
SilverDailyn/a 25550.598,055 USD-2,895
Brent CrudeDailyn/a 11960.504,755 EUR-4,645
GBP/USDDailyn/a 33459.883,432 USD-2,003
FTSE 100Dailyn/a 29754.552,325 EUR-948
GoldDailyn/a 28755.05624 EUR-317

Charts

Results by run

Net profit against max drawdown

Net profitMax drawdown
0-200K-100K500K1.0MUSD/JPY · DailyUSD/JPY · 4 hoursNikkei 225 · DailySilver · DailyBrent Crude · DailyGBP/USD · DailyFTSE 100 · DailyGold · Daily

The code

ProBuilder, rewritten to house standard

Every file in the library uses the same header, the same section order and the same variable names. The numbers above were produced by the original version before the rewrite, and the rewrite has not yet been compiled in ProRealTime.

// ============================================================
// Trend Breakout
// ProRealAlgos Strategy Library  |  prorealalgos.com
// Type: Breakout
// Direction: Long & short
// Timeframe tested: 4 hours
// ============================================================

// --- Settings ---
DEFPARAM CumulateOrders = false

// --- Parameters ---
positionSize = 1          // contracts per trade
fractalBars = 4           // bars the centre of the 5-bar fractal must beat, keep at 4
breakoutBars = 2          // bars for the breakout high / low
atrPeriod = 7             // ATR length for the entry buffer
atrMultiplier = 0.3       // entry buffer beyond the breakout level, in ATRs
bandPeriod = 34           // length of the log-price exponential bands
seedPeriod = 3            // SMA used to seed the bands on early bars
bandWidth = 1.618         // band width in standard deviations
rsiPeriod = 2             // RSI length for the exit
overboughtLevel = 85      // long exit needs RSI at or above this
oversoldLevel = 15        // short exit needs RSI at or below this
lookbackPeriod = 100      // window for the prior swing high / low

// State, seeded so every value is defined on the first bar.
ONCE fractalHighCount = 0
ONCE fractalLowCount = 0
ONCE trendBreak = 0
ONCE bearSetup = 0
ONCE bullSetup = 0
ONCE fractalHigh = 0
ONCE fractalLow = 0
ONCE fractalBar = 0
ONCE trendHeight = 0
ONCE closeHeight = 0
ONCE maxAngle = 0
ONCE logEma = 0
ONCE logVariance = 0
ONCE longExitArmed = 0
ONCE shortExitArmed = 0

// --- Indicators ---
// Count how many of the last five bars the bar two back beats.
FOR i = 0 TO fractalBars DO
  IF high[2] > high[i] THEN
    fractalHighCount = fractalHighCount + 1
  ENDIF
  IF low[2] < low[i] THEN
    fractalLowCount = fractalLowCount + 1
  ENDIF
NEXT

// A fractal high starts a bearish trend line, a fractal low a bullish one.
IF fractalHighCount = fractalBars THEN
  IF bearSetup = 0 AND bullSetup = 0 THEN
    bearSetup = 1
  ENDIF
  fractalHigh = high[2]
  fractalBar = BarIndex - 2
ENDIF
IF fractalLowCount = fractalBars THEN
  IF bearSetup = 0 AND bullSetup = 0 THEN
    bullSetup = 1
  ENDIF
  fractalLow = low[2]
  fractalBar = BarIndex - 2
ENDIF
fractalHighCount = 0
fractalLowCount = 0

IF bearSetup = 1 THEN
  trendHeight = fractalHigh - high
  closeHeight = fractalHigh - close
ELSIF bullSetup = 1 THEN
  trendHeight = low - fractalLow
  closeHeight = close - fractalLow
ENDIF

// Track the steepest angle of the trend line from the fractal, then detect
// a two-step break of that line (trendBreak 1, then 2).
IF BarIndex - 2 = fractalBar THEN
  maxAngle = Tan(2 / trendHeight)
ENDIF
IF BarIndex - 2 > fractalBar THEN
  IF bearSetup = 1 THEN
    IF Tan((BarIndex - fractalBar) / trendHeight) > maxAngle AND (close < open OR close < close[1]) THEN
      maxAngle = Tan((BarIndex - fractalBar) / trendHeight)
      trendBreak = 0
    ENDIF
    IF trendBreak = 0 AND Tan((BarIndex - fractalBar) / closeHeight) > maxAngle AND close > open THEN
      trendBreak = 1
    ELSIF trendBreak = 1 AND Tan(((BarIndex - 1) - fractalBar) / closeHeight) > maxAngle AND close > close[1] THEN
      trendBreak = 2
    ENDIF
  ELSIF bullSetup = 1 THEN
    IF Tan((BarIndex - fractalBar) / trendHeight) > maxAngle AND (close > open OR close > close[1]) THEN
      maxAngle = Tan((BarIndex - fractalBar) / trendHeight)
      trendBreak = 0
    ENDIF
    IF trendBreak = 0 AND Tan((BarIndex - fractalBar) / closeHeight) > maxAngle AND close < open THEN
      trendBreak = 1
    ELSIF trendBreak = 1 AND Tan(((BarIndex - 1) - fractalBar) / closeHeight) > maxAngle AND close < close[1] THEN
      trendBreak = 2
    ENDIF
  ENDIF
ENDIF

atrValue = AverageTrueRange[atrPeriod](close)

67 more lines: the entry and exit rules.

Read this first

Known weaknesses

  • No fixed stop loss or target. Exits depend on the band and RSI conditions only.
  • The exit-armed flag is never reset once set, so after the first armed exit the band condition no longer matters.
  • Profit factor was not recorded for any market. The best run on USD/JPY 4 hours made JPY 161,440 with a max drawdown of JPY 93,910.

Indicators used

ATRRSIBollinger Bands

How to load it

  1. Copy the code with the copy button above 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.

Questions

About this strategy

Can Trend Breakout run in ProOrder?

Yes, entries are pending stop orders valid for one bar. The code has been rewritten but not compile-checked, and the stats are from the earlier version.

What were the results by market?

All seven rows were profitable. USD/JPY Daily made JPY 754,540 over 300 trades, and Nikkei 225 Daily made USD 20,201.20.

How much drawdown per contract?

At 1 contract the best run had a max drawdown of JPY 93,910. Gold Daily was much smaller at EUR 317.10.

Why 4 hour and Daily bars?

Trend lines drawn from fractals need enough bars between swing points. Every tested row used 4 hour or Daily bars.

Related

Strategies like this one

Bollinger Squeeze

Uses the same indicator.

14.30 PF · 86 trades

Supertrend Counter Trend

Best run on the same market, USD/JPY.

3.47 PF · 1,444 trades

Breakout Regime Filter

Also a breakout strategy.

6.28 PF · 70 trades

Trend line breaks are hard to code by hand. See how we test ideas like this in the ProRealAlgos community.

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