A Breakout Trading System with Moving-Average Exits in Python
Summary
The article presents a simplified Turtle-style strategy coded for equities. It enters long when the close exceeds a recent rolling high and short when it falls below a rolling low, then exits when price crosses a rolling mean. Signals are carried forward to represent open positions, and daily log returns are multiplied by the prior day’s signal to form strategy returns. The code is applied to Apple, Kinder Morgan, and Ford, with cumulative returns plotted as a portfolio illustration.
The description calls for 55-day breakouts, but the implementation examples calculate rolling highs, lows, and means using five days and explicitly identify that window as a parameter to optimize. The article provides no numerical performance findings in the supplied text, nor does it describe out-of-sample validation or position sizing. It acknowledges that transaction costs are excluded and that the strategy carries risk. Those omissions limit what can be concluded from the illustrated returns, and the discrepancy between the stated and coded lookback periods needs resolving before interpreting results.
Key ideas
- The strategy enters positions when closing prices break above rolling highs or below rolling lows.
- A rolling mean crossing is used to exit long and short positions.
- Returns are calculated by applying the previous session’s signal to daily log returns.
- The text describes 55-day breakouts, while its code examples use a five-day rolling window.
- The illustrated performance excludes transaction costs and is not accompanied by reported validation results.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.