Momentum Strategy
The Momentum Strategy is a trend-following strategy that buys when price is trending upward and sells (or shorts) when price is trending downward. It aims to "ride the wave" of price movements.
How It Works
The strategy calculates momentum by comparing the current price to a price from N trades ago. If momentum is strong and positive, it goes long. If momentum is strong and negative, it goes short. It stays out of the market when momentum is weak.
Trading Logic:
Waits until at least lookback_window trades have occurred before trading
Prevents trading with incomplete data
Calculates momentum (positive = up, negative = down)
When momentum > momentum_threshold:
No position → BUY (enter long position)
Currently short → BUY (close short and flip to long)
Already long → Do nothing (stay in position)
When momentum < -momentum_threshold:
No position → SELL (enter short position)
Currently long → SELL (close long and flip to short)
Already short → Do nothing (stay in position)
When -momentum_threshold ≤ momentum ≤ momentum_threshold i.e. Weak Momentum (Neutral):
No action taken
Maintains current position (or stays out if no position)
Parameters
lookback_window (default: 10)
How many trades back to compare the current price against
Larger window = longer-term momentum, slower to react
Smaller window = shorter-term momentum, faster reactions
momentum_threshold (default: 0.005 = 0.5%)
Minimum percentage change required to trigger a trade
Acts as a filter to avoid trading on weak signals
Example: 0.005 means price must move at least 0.5% to trade
order_size (default: 100)
Dollar amount to trade when entering/exiting positions
initial_balance (default: 10000)
Starting capital for the strategy

Example Scenario
Setup: lookback_window=10, momentum_threshold=0.005 (0.5%)
Trade sequence:
Trades 1-9: No action (not enough data yet)
Trade 10:
Current price: $100, 10 trades ago: $100
Momentum: 0% → No action (below threshold)
Trade 20:
Current price: $106, 10 trades ago: $100
Momentum: 6% (> 0.5% threshold) → BUY (go long)
Trade 30:
Current price: $107, 10 trades ago: $104
Momentum: 2.9% (> 0.5% threshold) → Stay long
Trade 40:
Current price: $102, 10 trades ago: $107
Momentum: -4.7% (< -0.5% threshold) → SELL (close long, go short)
Trade 50:
Current price: $103, 10 trades ago: $103.2
Momentum: -0.19% (within threshold) → Stay short (no action)
Key Differences from Grid Strategy
Grid Strategy: Mean-reversion (buys dips, sells rallies) - assumes price oscillates
Momentum Strategy: Trend-following (buys strength, sells weakness) - assumes trends continue
Last updated