Designing a trend strategy

1 Introduction

Many quantitative strategies with extraordinary performance in backtests suffer from in-sample overfitting and data mining fallacies. If these data snooping faults are present in the construction of a quantitative strategy it may convince you that a strategy is better than it actually is. Naturally, these types of strategies perform poorly out-of-sample. One common approach which causes this fault is to optimise the lookback windows to give the best results in-sample. Historically these fitted values will have given you the best returns, but it is not certain that these fitted lookback windows will continue with their majestic performance going forward.

In this write-up, we investigate the performance of a trend strategy similar in spirit to the one we are currently employing, but we do so on fake data and with slightly different lookback windows. We are interested in creating a trend-following strategy that is capable of capturing trends. To this end, we create a collection of data series that have trends. On top of these trends, we superimpose Gaussian noise. The trendy data is shown in the plots below. The column on the left and right show sinusoidal and linear trends respectively. The specifications of the trendy time-series data are given in the table below.

comdty ref amplitude trend length volatility
SN 1 80 20 0.1
SN 2 80 40 0.1
SN 3 80 80 0.1
SN 4 80 160 0.1
SN 5 80 320 0.1
SN 6 80 80 0.2
SN 7 80 80 0.3
TR 1 100 25 0.1
TR 2 100 50 0.1
TR 3 100 100 0.1
TR 4 100 200 0.1
TR 5 100 400 0.1
TR 6 100 100 0.2
TR 7 100 100 0.3

Given the fake data above, will a simpletrend following strategy be able to capture the trends in the time-series above in a profitable way? Consider a trend strategy is made up of a collection of trend following trading rules

  • ewmac8
  • ewmac16
  • ewmac32
  • ewmac64
  • brk10
  • brk20
  • brk40
  • brk80
  • brk160
  • brk320

Here ewmac and brk denote the exponentially weighted moving average crossover and breakout strategies respectively. The integer next to the rule identifier denotes the length of the lookback. Smaller (larger) numbers have shorter (longer) lookbacks.

The plot below shows the equity curve generated by applying the trading rules above to all the fake data in equal weights. Notice that it created a positive performance over the test period, but not a pretty good one. In the following, we investigate the performance of the different strategies applied to each trendy time-series. Finally, we show how this simple strategy can be greatly improved by including volatility, correlations, and proper diversification.

2 P&L by trendy series

The plot below shows the P&L of each trendy series when blindly applying the system as defined in the introduction. Notice that when the trend is too short (case 1) and when the trend is too volatile (case 6) the system cannot extract positive P&L from the trendy series. These results are very much as expected.

Intuitively, if the lookback window of a breakout or exponentially weighted moving average crossover strategy is much longer than the duration of the trend it will not be able to generate profitable trading signals in that time frame. Similarly, if the lookback window is too short it will be stopped out too frequently and the penalty of the trading costs will cause the strategy to not be profitable.

3 P&L by trendy series and rules

In this section we delve a little deeper. Here we study the P&L of the different trading rules applied on each of the trendy time-series. When the lookback window of a trend rule is much larger than the length of the trend it is not able to identify the trend and will not be profitable. Conversely, very short lookback windows are able to identify longer term trends but are easily stopped out due to volatility. In this case the high trading frequency and cummulative costs cause the rule to have a flat or negative performance. This intuition is reflected in the analysis below. Note that the scale sin the y-axes below are independant of each other.

3.1 SN1

3.2 SN2

3.3 SN3

3.4 SN4

3.5 SN5

3.6 SN6

3.7 SN7

3.8 TR1

3.9 TR2

3.10 TR3

3.11 TR4

3.12 TR5

3.13 TR6

3.14 TR7

4 Adding bells and whistles

In this section, we explore what the effect of portfolio optimisation has on the P&L of the system. The initial construction showed in the introduction shows the P&L of a naive equally weighted portfolio. In the equally weighted portfolio, we do not account for correlations between time-series and forecasts on the time-series. Taking these effects into account using out-of-sample bagging leads to significant improvements in the performance of this simple systematic strategy.

4.1 Instrument weight estimates (IWE)

The first improvement is to consider the volatilities of the different time-series as well as the correlations of the returns of the time-series over a rolling period. We want to allocate less (more) to a more (less) volatile time-series. When two time-series are highly (weakly) correlated we reduce (increase) exposure to both of them. The results of this improvement are shown in the plot below.

4.2 Instrument and forecast weight estimates (IFWE)

We also have to take the volatilities and correlations of the different forecasts generated by our trading rules into account. The process is similar to that of the individual instruments. The results are given in the plot below.

4.3 Instrument, forecast weight and diversification multiplier estimates (IFDWE)

With increased diversification due to the first two improvemnts we reduce the risk as measured through the volatility by such an extend that we don’t hit our risk target. Accordingly P&L does not gain as we would like because we ae not taking enough risk. In this section we calculate a diversification multiplier which is used to hit our predefined risk target. We cap this value at 2.5 to avoid over exposure. The results of this improvement can be see in the plot below.

4.4 Instrument, forecast weight, diversification multiplier and forecast scale estimates (IFDWSE)

A good forecast needs to be a scaled quantity that we can more easily compare it with historical numbers. For the purpose of our trading system, we like all the forecasts to be scaled in such a way that the mean absolute forecast is set to 10. Furthermore, we cap the forecast at an absolute value of 20. The addition of the forecast scale estimate creates a rolling estimate that scales our forecasts according to the prescribed rules. Notice that the strategy initially performs poorly. This is the training phase of the system where we have not yet accumulated enough data to determine proper scaling coefficients. Once sufficient data is obtained it performs well. Results can be seen in the plot below.

4.5 Compare all post calibration

In this section we compare all five different portfolios

  • Equally Weighted EW
  • Instrument weight estimates (IWE)
  • Instrument, forecast weightestimates (IFWE)
  • Instrument, forecast weight and diversification multiplier estimates (IFDWE)
  • Instrument, forecast weight, diversification multiplier and forecast scale estimates (IFDSWE)

In the plot below we show port calibration results form 2004 onwards.

Notice that the post calibration results of IFDWE and IFDSWE are very similar and almost three times better than their nearest competitor. This is maindy due to the addition of the diversification multiplier.

5 Remarks

  • To profitably capture trends of different lengths you need to include a collection of strategies with different lookback windows that can see the trends.
  • Adjusting for time-series correlations and volatility greatly improves the results.
  • Adding diversification multipliers to hit target risk levels achieves the best results.
  • The simple rules, together with a couple of bells and whistles and correct out of smaple bagging can create a profitable trading strategy on trendy data.

6 Credits

Here we give credit where credit is due. This work is largely inspired by Rob Carver’s book

and a talk presented at Quantcon 2017

Avatar
Mauritz van den Worm
Portfolio Manager and Quantitative Researcher

My research interests include the use of artificial intelligence in managing commodity portfolios