1. Trend strategies: going with the market's flow
Level 5: Momentum, Mean-Reversion and Pairs Trading Strategies
Before programming any specific strategy, it helps to have a mental map of the big families of algorithmic strategies out there. The first two — trend and momentum — share an underlying intuition: that a price's recent movement carries useful information about its future movement.
Trend-based strategies aim to identify the general direction in which a market or an asset is moving, and to take positions in that same direction.
Trend following is the most direct form: buying assets that are rising and selling those that are falling, with the idea of holding the position for as long as the trend shows no clear signs of running out of steam.
Moving averages are the most common tool for spotting that direction: when a short-term moving average crosses above a long-term one, it is read as a buy signal — exactly the logic you are going to program in this very level.
Breakout strategies look for moments when the price leaves a defined range, clearing a support or resistance level, on the idea that breaking that range signals the trend is about to continue forcefully in that direction.
And channel trading identifies a channel — a band of prices between a support and a resistance — inside which the asset has been moving for some time, and takes positions according to where the price sits within that channel: buying near the lower edge, selling near the upper one.
Trend strategies work best in markets with clear, sustained directional moves; their weak spot is sideways markets, where the price oscillates without a defined direction and they generate false signals over and over again.
To go deeper into this lesson
- Momentumin the glossary
- Z-scorein the glossary
- Momentum investing: what it is and its S&P 500 recordguide