Aaron Fifield

Backtest: Trend Following Strategy

Introduction

user

Aaron Fifield

Trader, host of CWT.


Backtest: Trend Following Strategy

Posted by Aaron Fifield on .
Featured

Backtest: Trend Following Strategy

Posted by Aaron Fifield on .

This post details a portfolio-level backtest of the example trend following strategy discussed on Chat With Traders EP 178. The backtest was written in Python, using Jupyter Notebooks and historical data from Norgate.

Important: This strategy was given purely for demonstration purposes. The reason for backtesting is none other than a coding exercise.

Strategy:

  • Timeframe: End of day
  • Universe: S&P ASX Small Ordinaries
  • Benchmark: ASX 200 ETF (STW listed: 2001-08-27)
  • Backtest Period: 18-Years (2001-08-27 - 2019-08-31)
  • Starting Capital: $100,000
  • Commission: 5bps

Long Entry - Buy at close, if all conditions are true:

  • Breakout: Close above highest high of previous 100-days
  • Breakout Confirmation: Rate of change of previous 100-days greater than 30%
  • Regime Positive: ASX 200 above 200-day average
  • Volume Threshold: Position size less than 2% of 50-day average volume
  • Constituent: S&P ASX Small Ordinaries

Long Exit - Sell at close, if any conditions are true:

  • Trailing Stop (Regime Positive): 20% Below highest close
  • Trailing Stop (Regime Negative): 10% Below highest close
  • Delisted

Position Sizing:

  • Fixed position size, no compounding: Number of shares = 5% of starting capital / entry price
  • Maximum of 20 open positions, signals prioritised by greatest rate of change

Note: As discussed on EP 178, trades are filled at open of the following session. In this backtest, trades are filled at close of the same session.


Strategy Results - Plots:

  1. Backtest: 2001 - 2019 (Full performance)
  2. Backtest: 2015 - 2019 (Recent performance)
  3. Single stock: Best performer (CTX)
  4. Single stock: Worst performer (IRN)
  5. Backtest: 2001 - 2019 (Alternative universe: ASX 300)

1. Backtest: 2001 - 2019 (Full performance) - Click here to view full size

2. Backtest: 2015 - 2019 (Recent performance) - Click here to view full size

3. Single stock: Best performer (CTX) - Click here to view full size

4. Single stock: Worst performer (IRN) - Click here to view full size

5. Backtest: 2001 - 2019 (Alternative universe: ASX 300) - Click here to view full size


Compounding (guide only):

I've not taken time to accurately code how results would change if the account was to be compounded with each trade, i.e. number of shares = portfolio value / entry price. However, here's an approximate outcome:

If you have any questions about the above, Twitter is the best place to reach me: @chatwithtraders

user

Aaron Fifield

Trader, host of CWT.