The trigger is a KAMA line crossing the 22-period SMA, taken long or short. After an entry, one trade is allowed per signal cycle, which resets each day and after a trade closes. Exits use a 50 pip stop, a 200 pip target and a trailing lock that keeps a growing share of open profit.
Best run of 5. DAX 40, 4 hours, spread 3, from run pf:2026-09-15-DAX40-4h.tsv:1.
| Period | Up to 2026-09-15 |
| 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-16 |
| positionSize Contracts per trade | 1 |
| allowLong 1 = long trades allowed, 0 = banned | 1 |
| allowShort 1 = short trades allowed, 0 = banned | 1 |
| takeProfitPoints Fixed target in pips | 200 |
| stopLossPoints Fixed stop in pips | 50 |
| kamaPeriod KAMA efficiency ratio length | 2 |
| kamaFastPeriod KAMA fastest smoothing length | 2 |
| kamaSlowPeriod KAMA slowest smoothing length | 30 |
| slowPeriod SMA length | 22 |
| trailStartPoints Open profit in pips before the trailing stop starts | 10 |
| baseProfitShare Share of open profit locked in at the start | 0.1 |
| trailStepPoints Each chunk of this many pips raises the share | 6 |
| profitShareStep Share increase per chunk, relative to the base | 0.1 |
| roundingOffset -0.5 makes round() round down | -0.5 |
| profitShareCap Upper cap on the locked share | 100 |
| minDistancePips Closer than this, exit at market instead of a pending order | 7 |
Every run
| Market | Timeframe | PF | Trades | Win % | Net | Max DD |
|---|---|---|---|---|---|---|
| DAX 40Best run | 4 hours | 1.21 | 548 | 58.58 | 2,336 EUR | -1,352 |
| Dow Jones | Daily | 1.15 | 736 | 48.78 | 2,785 EUR | -1,212 |
| Silver | 4 hours | 0.40 | 7 | 57.14 | -453 USD | -969 |
| Gold | Daily | n/a | 28 | 60.71 | 311 EUR | -217 |
| S&P 500 | 4 hours | n/a | 5 | 80.00 | 189 EUR | -101 |
Charts
Above 1.0 made money, below 1.0 lost money.
The code
// ============================================================ // KAMA SMA Cross // ProRealAlgos Strategy Library | prorealalgos.com // Type: Trend // Direction: Long & short // Timeframe tested: 4 hours // ============================================================ // --- Settings --- DEFPARAM CumulateOrders = true DEFPARAM PreloadBars = 10000 // --- Parameters --- positionSize = 1 // contracts per trade allowLong = 1 // 1 = long trades allowed, 0 = banned allowShort = 1 // 1 = short trades allowed, 0 = banned takeProfitPoints = 200 // fixed target in pips stopLossPoints = 50 // fixed stop in pips kamaPeriod = 2 // KAMA efficiency ratio length kamaFastPeriod = 2 // KAMA fastest smoothing length kamaSlowPeriod = 30 // KAMA slowest smoothing length slowPeriod = 22 // SMA length trailStartPoints = 10 // open profit in pips before the trailing stop starts baseProfitShare = 0.1 // share of open profit locked in at the start trailStepPoints = 6 // each chunk of this many pips raises the share profitShareStep = 0.1 // share increase per chunk, relative to the base roundingOffset = -0.5 // -0.5 makes round() round down profitShareCap = 100 // upper cap on the locked share minDistancePips = 7 // closer than this, exit at market instead of a pending order // --- Indicators --- minStopDistance = minDistancePips * PipSize IF NOT OnMarket THEN barsInTrade = 0 ELSE barsInTrade = barsInTrade + 1 ENDIF // Kaufman adaptive moving average, built by hand fastestAlpha = 2 / (kamaFastPeriod + 1) slowestAlpha = 2 / (kamaSlowPeriod + 1) IF BarIndex >= (kamaPeriod + 1) THEN priceChange = abs(close - close[kamaPeriod]) pathLength = Summation[kamaPeriod](abs(close - close[1])) efficiencyRatio = priceChange / pathLength kamaAlpha = SQUARE(efficiencyRatio * (fastestAlpha - slowestAlpha) + slowestAlpha) kamaValue = (kamaAlpha * close) + ((1 - kamaAlpha) * kamaValue[1]) ELSE kamaValue = close ENDIF slowMA = Average[slowPeriod, 0](close)
78 more lines: the entry and exit rules.
Setup
Questions
Yes. The stop, target and trailing lock are built in, and it trades 1 contract with no pyramiding.
DAX 40 4 hours gave EUR 2,335.90 over 548 trades at profit factor 1.21. Dow Jones daily was similar at 1.15, while Silver 4 hours lost money.
At 1 contract the DAX 40 run had a max drawdown of EUR 1,351.90. That is more than half the net profit.
KAMA crosses on 4 hour DAX 40 bars happen often enough for a useful sample while the 50 pip stop still has room to work.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.