Join waitlist
Strategies / Trend / Swing Structure Trend Filter

Swing Structure Trend Filter

The strategy buys on the first bar where the latest 30 bar high is newer than the latest 30 bar low, close is above the 200 period EMA, and the 20 bar range exceeds 0.8 times ATR(20). It exits when the structure turns down.

TrendLong onlySwingGoldDaily
3.09Profit factor
3,656Net profit EUR
44.44%Win rate
126Trades
-809Max drawdown
29.01Avg trade

Best run of 30. Gold, Daily, spread 0.6, from run pf:2026-10-04-GOLD-D.tsv:1.

Entry rules, long

  1. The close is above the 200 period EMA.
  2. The 20 bar high minus low range exceeds 0.8 times the 20 bar ATR.
  3. Signals are considered only from bar 199 onward, and only on the first bar where all conditions are true.

Exit rules

  1. A protective stop sits 8 times the 14 period ATR below the entry price.

Test conditions

PeriodUp to 2026-10-04
InstrumentGold, Daily
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-04

Every run

Markets and timeframes tested

MarketTimeframePFTradesWin %NetMax DD
GoldBest runDaily3.09 12644.443,656 EUR-809
S&P 500Daily2.21 15341.833,966 EUR-962
Nikkei 2254 hours1.55 25640.6231,069 USD-7,362
USD/JPY4 hoursn/a 5861.7190,430 USD-63,960
Nikkei 225Dailyn/a 10144.5538,402 USD-13,871
Nikkei 2251 hourn/a 93439.6125,487 USD-11,232
Nikkei 22530 minn/a 1,87139.5523,020 USD-11,727
Dow JonesDailyn/a 15143.7118,913 EUR-5,864
Nasdaq 100Dailyn/a 10953.2117,410 EUR-4,480
Nikkei 2253 minn/a 1,90235.7513,492 USD-8,351
Nasdaq 1004 hoursn/a 32345.5112,851 EUR-4,661
Dow Jones1 hourn/a 37238.9812,765 EUR-5,154
Nasdaq 1001 hourn/a 1,17540.0910,913 EUR-3,471
Dow Jones4 hoursn/a 10642.4510,868 EUR-7,198
Nasdaq 10015 minn/a 1,98938.0110,402 EUR-3,430
DAX 4030 minn/a 2,13538.419,197 EUR-3,211
DAX 40Dailyn/a 14843.248,988 EUR-4,063
DAX 401 hourn/a 1,08940.778,361 EUR-3,406
Nasdaq 10030 minn/a 2,30741.097,753 EUR-3,825
Nasdaq 10010 minn/a 1,93936.317,312 EUR-3,520
Nasdaq 1005 minn/a 1,90435.293,887 EUR-3,430
DAX 404 hoursn/a 32740.673,764 EUR-3,510
Gold4 hoursn/a 28141.642,948 EUR-900
Gold1 hourn/a 1,05540.952,632 EUR-869
Gold30 minn/a 1,92438.882,519 EUR-701
S&P 5004 hoursn/a 34244.151,611 EUR-1,058
S&P 5001 hourn/a 1,18740.941,333 EUR-1,020
Gold15 minn/a 1,93533.591,147 EUR-562
Gold10 minn/a 1,95734.181,115 EUR-612
Gold5 minn/a 1,97035.28616 EUR-548

Charts

Results by run

Top 10 of 30 runs. The full list is in the table above.

Above 1.0 made money, below 1.0 lost money.

The code

ProBuilder code, as tested

// ==============================================================
// Swing Structure Trend Filter
// ProRealAlgos Strategy Library  |  prorealalgos.com
// Type: Trend
// Direction: Long only
// Timeframe tested: Daily
// ==============================================================

DEFPARAM CumulateOrders = false

ONCE phl = 0
ONCE pll = 0

swing = 30

34 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

ATREMA
Longer historyRe-run on up to 1,000,000 barsNikkei 225 · 4 hours · older data 383.70 USD

Nikkei 225 had no history beyond the standard run, so both runs used 22,000 bars.

Nikkei 225 · 4 hours

Bars available22,000
Net, standard 200,000-bar run31,069.20 USD
Net, long run31,452.90 USD
Net on the older data alone383.70 USD
Read this firstKnown weaknesses2 points
  • Results include the spread only. Commissions and overnight financing are not included.
  • The code is published as it was backtested and has not been compiled again since.

Questions

About this strategy

Can I run Swing Structure Trend Filter 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 30 market and timeframe combinations. The best run was Gold, Daily, with a profit factor of 3.09 over 126 trades.

How large was the drawdown?

The best run had a maximum drawdown of 809 EUR at the tested position size, against a net result of 3,656 EUR.

Does it trade long, short or both?

It only takes long trades.

Related

Strategies like this one

Reversal Pattern With Chaikin Volatility

Uses the same indicator.

2.26 PF · 6,872 trades

CCI Breakout

Best run on the same market, Gold.

1.08 PF · 6,065 trades

200-Period Average Upside Crossover

Also a trend strategy.

3.10 PF · 189 trades

Put your name on the ProRealAlgos waitlist to trade a tested portfolio instead of single strategies.

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