Backtesting a Long-Only Moving Average Crossover Strategy
Summary
This tutorial builds a simple long-only momentum strategy for AAPL using short and long simple moving averages. It buys when the shorter average rises above the longer one and sells when it falls below. The worked example uses 100-day and 400-day lookbacks, converts signals into fixed-share positions, and marks portfolio holdings using closing prices to produce an equity curve. Charts show price, averages, trade points, and portfolio value.
The article reports that this configuration lost money over the sample period and generated five round-trip trades. It attributes the outcome partly to the stock’s earlier decline and partly to the long lookbacks, which delayed the strategy’s response to a later rise. The example is framed as a basic implementation and comparison with a library example, not evidence that moving-average crossovers are generally unprofitable. It does not detail transaction costs, slippage, robustness checks, or parameter-selection safeguards, and its software dependencies are dated.
Key ideas
- A long-only crossover strategy enters when the short moving average exceeds the long moving average and exits when it falls below.
- The example applies 100-day and 400-day simple moving averages to AAPL.
- Portfolio returns are illustrated with a close-to-close equity curve and plotted trade markers.
- The reported backtest lost money and contained five round-trip trades.
- Long lookbacks may react slowly to a changing trend, while the example omits detailed cost and robustness analysis.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.