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.
Best run of 16. DAX 40, 5 min, spread 3, from run sweeps:2026-09-07-DAX40-5m-opt.tsv:21.
| Period | Up to 2026-09-07 |
| Instrument | DAX 40, 5 minutes |
| Spread | 3 points |
| Contracts | 1 |
| Starting capital | 1,000,000 |
| Costs | Spread only. Commissions and overnight financing are not included. |
| Bars | Up to 200,000 bars, fewer where the instrument has less history |
| Last tested | 2026-09-07 |
| 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
| Market | Timeframe | PF | Trades | Win % | Net | Max DD |
|---|---|---|---|---|---|---|
| DAX 40Best run | 5 min | n/a | 8,062 | 20.52 | -20,001 EUR | -20,186 |
| Gold | 30 min | n/a | 7,731 | 25.66 | 835 EUR | -3,080 |
| Gold | 1 hour | n/a | 4,354 | 24.41 | 76.10 EUR | -1,111 |
| Gold | 5 min | n/a | 7,921 | 20.10 | -1,894 EUR | -2,405 |
| Gold | 15 min | n/a | 7,904 | 19.93 | -2,880 EUR | -3,948 |
| DAX 40 | 1 hour | n/a | 4,077 | 27.13 | -5,331 EUR | -8,171 |
| S&P 500 | 1 hour | n/a | 4,395 | 23.53 | -5,754 EUR | -5,916 |
| S&P 500 | 30 min | n/a | 7,653 | 25.19 | -6,149 EUR | -8,130 |
| S&P 500 | 15 min | n/a | 7,701 | 21.71 | -6,927 EUR | -6,972 |
| S&P 500 | 5 min | n/a | 7,941 | 18.03 | -8,591 EUR | -8,595 |
| Nasdaq 100 | 30 min | n/a | 7,477 | 25.79 | -13,625 EUR | -19,051 |
| DAX 40 | 15 min | n/a | 7,666 | 23.52 | -14,402 EUR | -16,927 |
| DAX 40 | 30 min | n/a | 7,631 | 25.66 | -14,431 EUR | -18,631 |
| Nasdaq 100 | 15 min | n/a | 7,563 | 24.08 | -15,739 EUR | -16,278 |
| Nasdaq 100 | 5 min | n/a | 7,672 | 22.60 | -17,225 EUR | -17,257 |
| Nasdaq 100 | 1 hour | n/a | 4,403 | 23.37 | -17,362 EUR | -18,992 |
Charts
The code
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
Questions
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.
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.
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.
Pullback entries are a common idea, and knowing it failed on these markets and timeframes is useful before you spend time on it.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.