Join waitlist
Strategies / Trend / Trailing Line Four Bar Hold

Trailing Line Four Bar Hold

A trend-following system that trades crossovers of a volatility trailing line, filtered by MACD and a 50-bar EMA. It exits after 4 bars, or sooner on an opposite signal confirmed by the EMA and MACD.

TrendLong & shortSwingUSD/JPY4 hours
1.88Profit factor
410,190Net profit USD
55.45%Win rate
330Trades
-51,430Max drawdown
1,243Avg trade

Best run of 4. USD/JPY, 4 hours, spread 1, from run pf:2026-10-05-USDJPY-4h.tsv:1.

Entry rules, long

  1. MACD(12, 26, 9) is above its 9-bar signal line.
  2. The close and the low are both above the 50-bar EMA.
  3. A new signal is only taken when no signal is active, or more than 4 bars have passed since the last one.

Entry rules, short

  1. MACD(12, 26, 9) is below its 9-bar signal line.
  2. The close and the high are both below the 50-bar EMA.
  3. A new short signal is only taken when no signal is active, or more than 4 bars have passed since the last one.

Exit rules

  1. An opposite signal closes the trade earlier if the close is on the other side of the 50-bar EMA and MACD agrees.
  2. If a new signal fires on the exit bar, the new entry is skipped.

Test conditions

PeriodUp to 2026-10-05
InstrumentUSD/JPY, 4 hours
Spread1 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-05

Every run

Markets and timeframes tested

MarketTimeframePFTradesWin %NetMax DD
USD/JPYBest run4 hours1.88 33055.45410,190 USD-51,430
USD/JPYDailyn/a 16359.51573,020 USD-157,410
GBP/USDDailyn/a 18453.805,304 USD-1,867
Nikkei 2254 hoursn/a 24748.993,549 USD-3,022

Charts

Results by run

Net profitMax drawdown

The code

ProBuilder code, as tested

// ==============================================================
// Trailing Line Four Bar Hold
// ProRealAlgos Strategy Library  |  prorealalgos.com
// Type: Trend
// Direction: Long & short
// Timeframe tested: 4 hours
// ==============================================================

DEFPARAM CumulateOrders = false

ONCE ts = 0
ONCE started = 0
ONCE sigbar = -1
ONCE sigtype = 0
ONCE entrybar = 0

ema = ExponentialAverage[50](close)
myMacd = MACDLine[12,26,9](close)
macdsig = ExponentialAverage[9](myMacd)

nloss = 2.0 * TR(close)
prevts = ts
IF started = 0 THEN
    ts = close - nloss
    started = 1

61 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

True RangeEMAMACD
Longer historyRe-run on up to 1,000,000 barsUSD/JPY · 4 hours · older data 0.00 USD

USD/JPY had no history beyond the standard run, so both runs used 35,000 bars.

USD/JPY · 4 hours

Bars available35,000
Net, standard 200,000-bar run410,190.00 USD
Net, long run410,190.00 USD
Net on the older data alone0.00 USD
Read this firstKnown weaknesses2 points
  • The code sets no stop loss, so a losing trade stays open until an exit signal arrives.
  • Results include the spread only. Commissions and overnight financing are not included.

Questions

About this strategy

Can I run Trailing Line Four Bar Hold 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 4 market and timeframe combinations. The best run was USD/JPY, 4 hours, with a profit factor of 1.88 over 330 trades.

How large was the drawdown?

The best run had a maximum drawdown of 51,430 USD at the tested position size, against a net result of 410,190 USD.

Does it trade long, short or both?

It trades both long and short.

Related

Strategies like this one

Slow MACD Slope

Uses the same indicator.

6.80 PF · 7,305 trades

Trend Surfer

Best run on the same market, USD/JPY.

1.04 PF · 10,813 trades

EMA Pullback Short Continuation

Also a trend strategy.

1.87 PF · 36 trades

Want strategies that are already part of a live portfolio? Join the ProRealAlgos waitlist.

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