The strategy buys when the 8 day SMA is more than 3% above the 40 day SMA and sells when it falls more than 3% below. The 3% band is there to avoid flipping on small crosses. Position size is fully invested and compounding, starting from 100,000.
Best run of 31. DAX 40, Daily, spread 3, from run sweeps:2026-09-16-DAX40-D-opt.tsv:7.
| Period | Up to 2026-09-16 |
| Instrument | DAX 40, Daily |
| Spread | 3 points |
| 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-17 |
| startingCapital Account size at the start; profits are reinvested | 100000 |
| slowPeriod Slow SMA length | 40 |
| fastPeriod Fast SMA length | 8 |
| entryFactor Buy when the fast SMA is 3% above the slow SMA | 1.03 |
| exitFactor Sell when the fast SMA is 3% below the slow SMA | 0.97 |
Every run
| Market | Timeframe | PF | Trades | Win % | Net | Max DD |
|---|---|---|---|---|---|---|
| DAX 40Best run | Daily | n/a | 75 | 45.33 | 1,001,428 EUR | -442,242 |
| S&P 500 | Daily | n/a | 52 | 51.92 | 2,696,651 EUR | -474,949 |
| Nasdaq 100 | Daily | n/a | 70 | 55.71 | 1,927,541 EUR | -567,382 |
| Dow Jones | Daily | n/a | 56 | 51.79 | 1,207,794 EUR | -141,591 |
| Gold | Daily | n/a | 55 | 41.82 | 688,733 EUR | -296,382 |
| Nasdaq 100 | 1 hour | n/a | 19 | 42.11 | 514,204 EUR | -109,265 |
| Nasdaq 100 | 4 hours | n/a | 32 | 43.75 | 430,189 EUR | -111,923 |
| Nikkei 225 | Daily | n/a | 62 | 38.71 | 337,233 USD | -156,841 |
| Nasdaq 100 | 30 min | n/a | 7 | 57.14 | 322,945 EUR | -150,562 |
| FTSE 100 | Daily | n/a | 48 | 43.75 | 288,825 EUR | -160,310 |
| S&P 500 | 30 min | n/a | 4 | 75.00 | 266,591 EUR | -112,894 |
| DAX 40 | 4 hours | n/a | 25 | 56.00 | 236,733 EUR | -46,261 |
| Nikkei 225 | 4 hours | n/a | 23 | 43.48 | 236,358 USD | -61,322 |
| DAX 40 | 30 min | n/a | 7 | 57.14 | 214,681 EUR | -71,410 |
| S&P 500 | 4 hours | n/a | 17 | 35.29 | 187,078 EUR | -81,376 |
| DAX 40 | 1 hour | n/a | 19 | 42.11 | 180,192 EUR | -54,479 |
| Nikkei 225 | 1 hour | n/a | 15 | 53.33 | 160,519 USD | -60,819 |
| Nikkei 225 | 30 min | n/a | 10 | 50.00 | 139,020 USD | -67,234 |
| Brent Crude | 15 min | n/a | 26 | 53.85 | 133,582 EUR | -69,885 |
| Nasdaq 100 | 15 min | n/a | 4 | 50.00 | 120,330 EUR | -89,517 |
| Gold | 1 hour | n/a | 7 | 85.71 | 113,950 EUR | -46,065 |
| Brent Crude | 10 min | n/a | 11 | 63.64 | 112,513 EUR | -67,522 |
| S&P 500 | 15 min | n/a | 3 | 33.33 | 93,977 EUR | -60,940 |
| DAX 40 | 15 min | n/a | 3 | 33.33 | 90,983 EUR | -40,965 |
| S&P 500 | 1 hour | n/a | 16 | 50.00 | 65,974 EUR | -43,648 |
| Dow Jones | 15 min | n/a | 3 | 33.33 | 65,816 EUR | -46,465 |
| FTSE 100 | 4 hours | n/a | 15 | 46.67 | 65,627 EUR | -43,405 |
| Dow Jones | 4 hours | n/a | 5 | 60.00 | 48,699 EUR | -39,048 |
| FTSE 100 | 30 min | n/a | 4 | 75.00 | 44,763 EUR | -35,158 |
| Dow Jones | 1 hour | n/a | 5 | 60.00 | 33,124 EUR | -31,973 |
| FTSE 100 | 15 min | n/a | 2 | 50.00 | 26,849 EUR | -22,889 |
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.
// ============================================================ // Rule Based MA Band // ProRealAlgos Strategy Library | prorealalgos.com // Type: Trend // Direction: Long only // Timeframe tested: Daily // ============================================================ // --- Settings --- DEFPARAM CumulateOrders = false DEFPARAM PreloadBars = 10000 // --- Parameters --- startingCapital = 100000 // account size at the start; profits are reinvested slowPeriod = 40 // slow SMA length fastPeriod = 8 // fast SMA length entryFactor = 1.03 // buy when the fast SMA is 3% above the slow SMA exitFactor = 0.97 // sell when the fast SMA is 3% below the slow SMA // --- Indicators --- // Fully invested: size is current equity divided by price, so it compounds. accountEquity = startingCapital + StrategyProfit positionSize = accountEquity / close slowMA = Average[slowPeriod](close) upperBand = slowMA*entryFactor lowerBand = slowMA*exitFactor fastMA = Average[fastPeriod](close)
14 more lines: the entry and exit rules.
Read this first
Questions
Yes, but the compounding share based sizing needs a broker account that allows it. Check the position size logic before going live.
All 30 runs were profitable, led by S&P 500 Daily at EUR 2,696,650.83 and Nasdaq 100 Daily at EUR 1,927,541.43. These figures reflect compounding from 100,000, not 1 contract.
The code starts from 100,000 and reinvests all profit. On DAX 40 Daily the max drawdown was EUR 442,241.61, so expect large swings in account value.
The 8 and 40 day averages are built to catch trends lasting weeks to months. On intraday bars they produce very few trades.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.