Systemicalpha

EMA crossover

A trend-following strategy that buys when a fast exponential moving average crosses above a slow one and sells when it crosses back below.

The indicator

An exponential moving average weights recent prices more heavily than older ones. With a smoothing factor α=2/(n+1)\alpha = 2/(n+1) the recursion is

EMAt=α⋅pt+(1−α)⋅EMAt−1\text{EMA}_t = \alpha \cdot p_t + (1 - \alpha) \cdot \text{EMA}_{t-1}

where ptp_t is the close price at bar tt and nn is the period.

Choosing periods

FastSlowCharacter
921Reactive, more signals
1226The MACD defaults
50200Slow, filters most of the noise

The graph

flowchart LR
  P[Price source] --> F[EMA fast]
  P --> S[EMA slow]
  F --> X[Crossover]
  S --> X
  X -->|up| B[Buy]
  X -->|down| L[Sell]

Signal logic

The crossover module emits 1 on the bar where the fast line moves above the slow line, -1 where it drops below, and 0 otherwise:

def crossover(fast, slow):
    above = fast > slow
    return above.astype(int).diff().fillna(0)

Backtest

Run the strategy over at least one full market cycle before trusting it. Trend followers lose in sideways markets, so the equity curve should be judged on drawdown as much as on return.

Rendering diagrams...
© 2026 WanoLabs. All rights reservedAlpha build v0.1.5