The idea is to buy a bounce after a decline. It enters long when the close sits above the 50 EMA but below the 100 EMA, closes higher than the previous bar, and the 100-bar regression slope is still negative. Trades exit at a 2.75% target, a 10% stop, or when the close slips below the 7 EMA while staying above the 28 EMA.
Best run of 10. DAX 40, 4 hours, spread 3, from run pf:2026-09-24-DAX40-4h.tsv:4.
| Period | Up to 2026-09-25 |
| Instrument | DAX 40, 4 hours |
| 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-25 |
| positionSize Contracts per trade | 1 |
| fastPeriod EMA close must be above | 50 |
| slowPeriod EMA close must be below | 100 |
| slopePeriod Regression slope length | 100 |
| exitFastPeriod Exit EMA, fast | 7 |
| exitSlowPeriod Exit EMA, slow | 28 |
| stopLossPct Protective stop, percent | 10 |
| takeProfitPct Profit target, percent | 2.75 |
Every run
| Market | Timeframe | PF | Trades | Win % | Net | Max DD |
|---|---|---|---|---|---|---|
| DAX 40Best run | 4 hours | 1.88 | 312 | 52.24 | 11,042 EUR | -2,379 |
| Nikkei 225 | 4 hours | n/a | 237 | 54.01 | 14,883 USD | -6,264 |
| Dow Jones | 4 hours | n/a | 80 | 52.50 | 11,974 EUR | -2,523 |
| Dow Jones | Daily | n/a | 115 | 52.17 | 9,031 EUR | -2,364 |
| US Crude Oil | 4 hours | n/a | 267 | 53.18 | 4,896 EUR | -1,304 |
| Nasdaq 100 | 1 hour | n/a | 1,140 | 42.19 | 4,650 EUR | -2,798 |
| Nasdaq 100 | 30 min | n/a | 1,825 | 42.58 | 4,458 EUR | -2,282 |
| FTSE 100 | 4 hours | n/a | 308 | 51.30 | 4,000 EUR | -1,154 |
| Silver | Daily | n/a | 168 | 56.55 | 3,809 USD | -3,597 |
| S&P 500 | 4 hours | n/a | 239 | 58.16 | 1,689 EUR | -1,003 |
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.
// ============================================================ // Buy After Price Fall // ProRealAlgos Strategy Library | prorealalgos.com // Type: Mean reversion // Direction: Long only // Timeframe tested: 4 hours // ============================================================ // --- Settings --- DEFPARAM CumulateOrders = false // --- Parameters --- positionSize = 1 // contracts per trade fastPeriod = 50 // close must be above this EMA slowPeriod = 100 // close must be below this EMA slopePeriod = 100 // regression slope length, must be falling exitFastPeriod = 7 // exit EMA, close must drop below it exitSlowPeriod = 28 // exit EMA, close must still be above it stopLossPct = 10 // protective stop, percent of entry price takeProfitPct = 2.75 // profit target, percent of entry price // --- Indicators --- fastMA = ExponentialAverage[fastPeriod](close) slowMA = ExponentialAverage[slowPeriod](close) regressionSlope = LinearRegressionSlope[slopePeriod](close) exitFastMA = ExponentialAverage[exitFastPeriod](close) exitSlowMA = ExponentialAverage[exitSlowPeriod](close)
18 more lines: the entry and exit rules.
Read this first
Questions
Yes, it uses standard entries and exits. The code was rewritten after testing and not compile-checked, so verify it in ProBacktest before live use.
All 9 other runs in the table were profitable, including Nikkei 225 4 hours at USD 14,882.5 and Dow Jones 4 hours at EUR 11,974. S&P 500 4 hours made the least, EUR 1,688.92.
The DAX 40 best run had a max drawdown of EUR 2,378.6 against EUR 11,042 net profit at a position size of 1.
The 4 hour timeframe gave the best DAX result and most of the strongest rows in the table, which suits a pullback system that holds for several bars.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.