Join today
Strategies / Trend / Pullback to Moving Average

Pullback to Moving Average

With the close above the 200-period SMA, a cross back above the 20-period SMA opens a long. Shorts mirror this below the 200 SMA. Positions close on a cross of the 50-period SMA or at a 1% stop.

TrendLong & shortIntradayDAX 405 min
n/aProfit factor
-20,001Net profit EUR
20.52%Win rate
8,062Trades
-20,186Max drawdown
-2.48Avg trade

Best run of 16. DAX 40, 5 min, spread 3, from run sweeps:2026-09-07-DAX40-5m-opt.tsv:21.

Entry rules, long

  1. Close is above the 200-period SMA
  2. Members only
  3. No position is open

Entry rules, short

  1. Close is below the 200-period SMA
  2. Members only
  3. No position is open

Exit rules

  1. Stop loss at 1% from entry
  2. Members only
  3. Close a short when the close is above the 50-period SMA

Test conditions

PeriodUp to 2026-09-07
InstrumentDAX 40, 5 minutes
Spread3 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-07

Parameters

positionSize
Contracts per trade
1
trendPeriod
Trend SMA length
200
pullbackPeriod
Pullback SMA length
20
exitPeriod
Exit SMA length
50
stopLossPct
Protective stop, percent
1

Every run

Markets and timeframes tested

MarketTimeframePFTradesWin %NetMax DD
DAX 40Best run5 minn/a 8,06220.52-20,001 EUR-20,186
Gold30 minn/a 7,73125.66835 EUR-3,080
Gold1 hourn/a 4,35424.4176.10 EUR-1,111
Gold5 minn/a 7,92120.10-1,894 EUR-2,405
Gold15 minn/a 7,90419.93-2,880 EUR-3,948
DAX 401 hourn/a 4,07727.13-5,331 EUR-8,171
S&P 5001 hourn/a 4,39523.53-5,754 EUR-5,916
S&P 50030 minn/a 7,65325.19-6,149 EUR-8,130
S&P 50015 minn/a 7,70121.71-6,927 EUR-6,972
S&P 5005 minn/a 7,94118.03-8,591 EUR-8,595
Nasdaq 10030 minn/a 7,47725.79-13,625 EUR-19,051
DAX 4015 minn/a 7,66623.52-14,402 EUR-16,927
DAX 4030 minn/a 7,63125.66-14,431 EUR-18,631
Nasdaq 10015 minn/a 7,56324.08-15,739 EUR-16,278
Nasdaq 1005 minn/a 7,67222.60-17,225 EUR-17,257
Nasdaq 1001 hourn/a 4,40323.37-17,362 EUR-18,992

Charts

Results by run

Net profit against max drawdown

Net profitMax drawdown
0-25K-13K5001KGold · 30 minGold · 1 hourGold · 5 minGold · 15 minDAX 40 · 1 hourS&P 500 · 1 hourS&P 500 · 30 minS&P 500 · 15 minS&P 500 · 5 minNasdaq 100 · 30 minDAX 40 · 15 minDAX 40 · 30 minNasdaq 100 · 15 minNasdaq 100 · 5 minNasdaq 100 · 1 hourDAX 40 · 5 min

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.

// ============================================================
// Pullback to Moving Average
// ProRealAlgos Strategy Library  |  prorealalgos.com
// Type: Trend
// Direction: Long & short
// Timeframe tested: 5 minutes
// ============================================================

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

// --- Parameters ---
positionSize = 1          // contracts per trade
trendPeriod = 200         // SMA that sets the trend direction
pullbackPeriod = 20       // SMA price must cross back over to re-enter the trend
exitPeriod = 50           // SMA that closes the trade
stopLossPct = 1           // protective stop, percent of entry price

// --- Indicators ---
trendMA = Average[trendPeriod](close)
pullbackMA = Average[pullbackPeriod](close)
exitMA = Average[exitPeriod](close)

25 more lines: the entry and exit rules.

Read this first

Known weaknesses

  • It lost money on almost every market. The run shown in the key stats, DAX 40 5 minutes, finished at EUR -20,001.40 over 8,062 trades.
  • Win rate was 20.52% in that run and the average trade was EUR -2.48, so costs alone push it negative.
  • Only Gold 30 minutes (EUR 834.80) and Gold 1 hour (EUR 76.10) ended positive.
  • Profit factor was not recorded. All rows are sweep data.

Indicators used

SMA

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 this run in ProOrder?

It can, but the tests do not support running it as is. The code is a rewrite without a compile check, and the losing stats come from the earlier version.

Which markets were tested?

DAX 40, Gold, S&P 500 and Nasdaq 100 on 5 minutes to 1 hour. All Nasdaq 100, S&P 500 and DAX 40 runs lost money.

How deep were the drawdowns?

At 1 contract, DAX 40 5 minutes had a max drawdown of EUR 20,185.60. Nasdaq 100 30 minutes reached EUR 19,051.40.

Why publish a losing strategy?

Pullback entries are a common idea, and knowing it failed on these markets and timeframes is useful before you spend time on it.

Related

Strategies like this one

Bollinger Squeeze

Uses the same indicator.

14.30 PF · 86 trades

Buy After Price Fall

Best run on the same market, DAX 40.

1.88 PF · 312 trades

Long-Term Moving Average Cross

Also a trend strategy.

12.31 PF · 61 trades

We test the ideas that fail too. Join the ProRealAlgos community to see which ones pass.

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