Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Momentum

Momentum is a trend-following strategy that uses an EMA crossover to generate directional signals.

Algorithm

  1. Maintain a fast EMA (default period 12) and a slow EMA (default period 26) over trade prices.
  2. When fast EMA crosses above slow EMA: emit a buy signal.
  3. When fast EMA crosses below slow EMA: emit a sell signal.
  4. No signal is emitted until both EMAs have warmed up (require slow_period trades).

Parameters

ParameterDefaultDescription
fast_period12Fast EMA period
slow_period26Slow EMA period
order_qtydec!(0.01)Order size per signal