Join today
Strategies / Trend / KAMA SMA Cross

KAMA SMA Cross Strategy

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.

TrendLong & shortSwingDAX 404 hours
1.21Profit factor
2,336Net profit EUR
58.58%Win rate
548Trades
-1,352Max drawdown
4.26Avg trade

Best run of 5. DAX 40, 4 hours, spread 3, from run pf:2026-09-15-DAX40-4h.tsv:1.

Entry rules, long

  1. Members only
  2. No position is open
  3. No trade has been taken yet in the current signal cycle (re-armed each new day and after each trade closes)

Entry rules, short

  1. Members only
  2. No position is open
  3. No trade has been taken yet in the current signal cycle (re-armed each new day and after each trade closes)

Exit rules

  1. Fixed target of 200 pips
  2. Fixed stop loss of 50 pips
  3. Members only
  4. The locked-in level is placed as a stop or limit order, or the trade is closed at market if price is within 7 pips of it

Test conditions

PeriodUp to 2026-09-15
InstrumentDAX 40, 4 hours
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-16

Parameters

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

Markets and timeframes tested

MarketTimeframePFTradesWin %NetMax DD
DAX 40Best run4 hours1.21 54858.582,336 EUR-1,352
Dow JonesDaily1.15 73648.782,785 EUR-1,212
Silver4 hours0.40 757.14-453 USD-969
GoldDailyn/a 2860.71311 EUR-217
S&P 5004 hoursn/a 580.00189 EUR-101

Charts

Results by run

Profit factor by run

Above 1.0 made money, below 1.0 lost money.

0.00.51.01.52.01.0 = break-evenDAX 40 · 4 hours1.21Dow Jones · Daily1.15Silver · 4 hours0.40

Net profit against max drawdown

Net profitMax drawdown
0-2K-1K3K5KDow Jones · DailyDAX 40 · 4 hoursGold · DailyS&P 500 · 4 hoursSilver · 4 hours

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.

// ============================================================
// 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.

Read this first

Known weaknesses

  • Profit factor on the best run is only 1.21, with an average trade of EUR 4.26, so small cost changes matter.
  • Silver 4 hours ended at USD -452.50 with a profit factor of 0.4, though on only 7 trades.
  • Gold daily (28 trades) and S&P 500 4 hours (5 trades) have too few trades to judge.
  • The original idea used a 1 hour signal across timeframes. The tested code runs everything on one chart timeframe, which is a different system.

Indicators used

KAMASMA

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

Is it ready for ProOrder?

Yes. The stop, target and trailing lock are built in, and it trades 1 contract with no pyramiding.

What were the test results?

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.

How much drawdown did it have?

At 1 contract the DAX 40 run had a max drawdown of EUR 1,351.90. That is more than half the net profit.

Why 4 hour bars?

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

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

EMA 20/50 Cross

A similar profit factor.

1.22 PF · 1,288 trades

Moving average crosses rarely work alone. Join the ProRealAlgos waitlist to see what pairs with them.

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