Join waitlist
Strategies / Trend / Trend Filtered MACD Trailing Exit

Trend Filtered MACD Trailing Exit

A trend-following system that enters with the 99-period EMA, ADX above 20 and MACD confirming. It exits at market when open profit falls to 97% of its peak once that peak reaches 0.5%, and uses a 2.5 ATR stop.

TrendLong & shortSwingSilver1 hour
n/aProfit factor
367,414Net profit USD
53.01%Win rate
4,150Trades
-161,272Max drawdown
88.53Avg trade

Best run of 5. Silver, 1 hour, spread 2, from run sweeps:2026-10-03-SILVER-1h-opt.tsv:7.

Entry rules, long

  1. The close is above the 99-period EMA, and the EMA is higher than it was 3 bars ago.
  2. ADX(11) is above 20 and volume is above 0.6 times its 22-bar average.
  3. Alternatively, MACD is above its signal with a positive histogram and the close is above the prior 5-bar high.
  4. At least 3 bars must have passed since the previous entry.
  5. Entries are only taken after 120 bars of history.

Entry rules, short

  1. The close is below the 99-period EMA, and the EMA is lower than it was 3 bars ago.
  2. ADX(11) is above 20 and volume is above 0.6 times its 22-bar average.
  3. Alternatively, MACD is below its signal with a negative histogram and the close is below the prior 5-bar low.
  4. At least 3 bars must have passed since the previous entry.
  5. Entries are only taken after 120 bars of history.

Exit rules

  1. An emergency stop sits 2.5 times ATR(18) from the fill price.

Test conditions

PeriodUp to 2026-10-03
InstrumentSilver, 1 hour
Spread2 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-03

Every run

Markets and timeframes tested

MarketTimeframePFTradesWin %NetMax DD
SilverBest run1 hourn/a 4,15053.01367,414 USD-161,272
USD/JPYDailyn/a 4821.8749,890 USD-27,040
Nasdaq 1001 hourn/a 2,07951.5210,302 EUR-3,996
Brent Crude4 hoursn/a 82462.997,626 EUR-2,738
GoldDailyn/a 26564.151,651 EUR-620

Charts

Results by run

Net profitMax drawdown

The code

ProBuilder code, as tested

// ==============================================================
// Trend Filtered MACD Trailing Exit
// ProRealAlgos Strategy Library  |  prorealalgos.com
// Type: Trend
// Direction: Long & short
// Timeframe tested: 1 hour
// ==============================================================

DEFPARAM CumulateOrders = false

ONCE lastbull = -1
ONCE lastbear = -1
ONCE lastentry = -1
ONCE peak = 0
ONCE peakset = 0
ONCE armed = 0

fastema = ExponentialAverage[14](close)
slowema = ExponentialAverage[39](close)
myMacd = fastema - slowema
signal = ExponentialAverage[9](myMacd)
hist = myMacd - signal

trend = ExponentialAverage[99](close)
myAdx = ADX[11]
volsma = Average[22](volume)
myAtr = AverageTrueRange[18](close)

85 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

ADXATREMAMACDSMAVolume
Read this firstKnown weaknesses2 points
  • No profit factor is available, because only sweep results exist for this strategy.
  • Results include the spread only. Commissions and overnight financing are not included.

Questions

About this strategy

Can I run Trend Filtered MACD Trailing Exit 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 5 market and timeframe combinations. The best run by trade count was Silver, 1 hour, with 4,150 trades.

How large was the drawdown?

The best run had a maximum drawdown of 161,272 USD at the tested position size, against a net result of 367,414 USD.

Does it trade long, short or both?

It trades both long and short.

Related

Strategies like this one

Trend Surfer

Uses the same indicator.

1.04 PF · 10,813 trades

SMA Crossover With RSI Exit

Best run on the same market, Silver.

2.13 PF · 8,999 trades

ADX Filtered EMA Cross

Also a trend strategy.

1.15 PF · 607 trades

See how ProRealAlgos combines strategies like this into one automated portfolio.

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