EMA Cross Momentum

Fast EMA(9) crossing above slow EMA(21) rides short-term momentum; the reverse cross exits. Trend-following 101.

By STLab · Published 2026-06-12 · CC-BY-SA-4.0

Reliability

Read with caution — from 19 trades, fewer than the 30 a result needs to mean much.

Backtest result

Return+18.1%
Sharpe0.24
Max drawdown8.5%
Profit factor2.00
Win rate36.8%
Trades19

Run on AAPL 1h · 6m · 853 bars · data from yahoo. Frozen at publish time, captured 2026-07-15.

Strategy code

import stlab

fast = stlab.indicators.ema(stlab.candles.close, period=9)
slow = stlab.indicators.ema(stlab.candles.close, period=21)

cross_up = (fast.shift(1) < slow.shift(1)) & (fast >= slow)
cross_down = (fast.shift(1) > slow.shift(1)) & (fast <= slow)

stlab.signal.long_when(cross_up)
stlab.signal.exit_when(cross_down)

stlab.position.size(percent=100)
stlab.position.stop_loss(percent=3)
stlab.position.take_profit(percent=9)

All published strategies