Trend following is an investment strategy based on technical analysis. The basic premise is that the market can be regarded either as a bull market or a bear market at a given time.

Trend followers take advantage of these trends and make their buying and selling decisions. Rather than focusing on predicting specific price levels as in other areas of technical analysis, trend followers simply jump on the trend and ride through it.

There are a several different ways and various time frames to determine the general market directions. Traditionally, moving averages and channel breakouts are used to determine current market trends. Here we focus on a brand new trend following approach developed by Dai, Zhang, and Zhu [1].

This approach starts with two assumptions: (1) The stock prices follow a bull-bear switching geometric Brownian motion; (2) The switching process is a hidden Markov chain.

Under these assumptions, we are able to compute the conditional probability {p(n): n=0,1,2,…} of a bull market given the past stock daily closing prices S(0),S(1),…,S(n) with S(n) being the most recent price.

Our trading rules are based purely on the readings of p(n). To facilitate our exposition, we introduce the following notation:

M1: annual bull market return rate,

M2: annual bear market return rate,

1/L1: average duration of bull markets,

1/L2: average duration of bear markets,

V: stock volatility,

dt: time unit 1/252.

For example, using DJIA (1962-2008), we can estimate these parameters and have M1=0.18, M2=-0.77, L1=0.36, L2=2.53, and V= 0.184.

The conditional probability p(n), n=1,2,…, can be obtained as follows:

**p(n)=min{max{p(n-1)+F(p(n-1))*dt+[[(M1-M2)*p(n-1)*(1-p(n-1))]/(V*V)]*ln(S(n)/S(n-1)),0},1},**

where **p(0)** is an initial guess taking value in [0,1] and

**F(p)=-(L1+L2)*p+L2-{(M1-M2)*p*(1-p)*[(M1-M2)*p+M2-0.5*V*V]}/(V*V).**

Note that **p(n)** stays in [0,1] for all n. It behaves pretty much like a traditional indicator (e.g., RSI) in technical analysis. Nonetheless, the way it is used in determining market trends is quite different from that of RSI.

In the above figure, the red curve represents DJIA from 1960 to 1981 and the blue curve the corresponding conditional probability **p(n)**.

We only consider the long-side of trading, i.e., go long in a bull market and sit on the sideline in a bear market.

Assuming a fixed percentage transaction cost, it is shown in [1] that the optimal trading rules can be given in terms of two threshold levels BL>SL. For example, using the DJIA (1962-2008) estimates, we can obtain BL=0.934 and SL=0.768. These two threshold levels can be seen in Figure (DJIA: 1960-1980). The TF trading rule is to buy when **p(n)** crosses BL from below and close the long position when p(n) crosses SL from above.

We test our trend following strategy on the historical data of SP500 (1962-2008), DJIA (1962-2008) and NASDAQ (1991-2008) indices. In these tests we assume the transaction cost K=0.1% and use 10 year treasury bond as the alternative risk-free investment instrument. We use the actual yield when holding the bonds. The test results for the total (annual) returns of this trend following strategy on the three indices are contrasted with buy and hold and invest in bond in the following table.

Indices | Period | Trend Following | Buy and Hold | 10yr Bond | #Trades |

NASDAQ | 1991-2008 | 8.82(12.86%) | 4.24 | 2.63 | 66 |

SP500 | 1962-2008 | 64.98(10.00%) | 56.2 | 23.44 | 80 |

DJIA | 1962-2008 | 26.03(7.18%) | 12.11 | 23.44 | 80 |

The graphic illustration of these results are presented in Figures log(NASDAQ: 1991-2008), (log(SP500): 1962-2008) and (log(DJIA): 1962-2008)), respectively, where the blue part is the return of the trend following strategy in log scale.

We should be clear that the results described here is not intended for using directly as an investment strategy. To develop this model into a useful investment strategy one needs to address several important issues: (1) go beyond the tests of the three indices and use techniques such as withhold samples to avoid backtest overfitting; (2) diversify to make the strategy more stable; and (3) control the risks using various mechanisms. Nevertheless, these results demonstrate how mathematics can be useful in making trading decisions. Further studies of the trend following can be found in [2] and [3].

**References:**

[1] M. Dai, Q. Zhang, and Q. Zhu, Trend following trading under a regime switching model, SIAM Journal on Financial Mathematics, Vol. 1, pp. 780-810, (2010).

[2] M. Dai, Q. Zhang, and Q. Zhu, Optimal trend-following trading rules, Working paper, (available upon request).

[3] D. Nguyen, G. Yin, and Q. Zhang, A stochastic approximation approach for trend-following trading, Hidden Markov Models in Finance: Volume II (Further Developments and Applications), Springer, R.S. Mamon and R.J. Elliott, Eds.