This study investigates five popular technical indicators. The first two, namely RSI and STOCH, are based on the contrarian idea. Basically, when the stock is overbought (oversold), the price tends to decrease (increase) afterward. The next two, namely MACD and DMI, are trend-following indicators. By riding a trend, technical analysis asserts that investors could make profits. The last indicator, OBV, is a volume-based indicator. It shows whether volume is flowing into or out of a security.
Each indicator is characterized by a number of parameters called “Ns”, i.e. N1, N2, N3 and so forth. The “standard” values for these parameters are the most popular numbers used by technical traders as reported in Colby (2003). On the other hand, the “optimal” values for these parameters are the ones that maximize net profits.
The simulated portfolio set up for testing each trading rule follow the following rules. When there are no signals, the entire portfolio consists of only cash deposit with no interest just to be conservative. For long-only strategies, if there is a buy signal on any particular day, then our simulated investor would use the entire cash to buy stocks the following trading day at the opening price. He will hold these stocks as long as there is no sell signal. When he gets a sell signal on any particular day, he will liquidate all stocks holding into cash on the following trading day at the opening price. For short-only strategies, the rules are similar but with opposite transactions. All long and short positions are closed at the end of the simulation. Transaction costs are ignored at this stage as their impact would be investigated with the round-trip breakeven costs later.
The detail of each trading rule is as follow.
Relative Strength Index (RSI)
The RSI measures the current and historical strength or weakness of stock or market price movements based on closing prices of a recent trading period. Stocks which have had stronger positive changes have a higher RSI than stocks which have had stronger negative changes.
The idea behind is that when price moves up very rapidly, at some point it is considered overbought. Likewise, when price falls very rapidly, at some point it is considered oversold. In either case, a reversal is to be expected.
The RSI ranges from 0 to 100, with high and low levels marked at 70 and 30, respectively. Traditionally, RSI readings greater than the 70 level are considered to be in an overbought territory (Bearish signal), whereas RSI readings lower than the 30 level are considered to be in an oversold territory (Bullish signal). In between the 30 and 70 level is considered neutral, with the 50 level a sign of no trend.
Mathematically, the RSI is calculated by the following steps. First, calculate the “U” and “D” variables. The variable “U” equals an increase in price when a price moves up and zero otherwise. In opposite, the variable “D” equals an (absolute) decrease in price when a price moves down and zero otherwise. Second, compute average “U” (Ua) and average “D” (Da) by doing exponential moving averages of “U” and “D” over “N1” periods, respectively. The RSI is defined by the following equation.
$$RSI(P,N1) = \frac{Ua(P,N1)}{[Ua(P,N1) + Da(P,N1)]} \times 100$$
P
t
is the closing price at time “t”
The standard value for “N1” is 14 (Colby 2003). This paper also searches for an optimal parameter value and then compares results with that from a standard parameter.
The buy signal to enter a long position (or to cover a prior short position) is generated when the RSI is in an oversold territory (RSI < 30). On the other hand, the sell signal to enter a short position (or to close a prior long position) is generated when the RSI is in an overbought territory (RSI > 70).
Stochastic oscillator (STOCH)
The stochastic oscillator is an indicator that uses support and resistance levels in an attempt to anticipate price turning points. Its value is determined by the location of a current price in relation to its price range over a period of time.
Basically, the current security’s price is expressed as a percentage of this range with 0 % indicating the bottom of the range and 100 % indicating the upper limits of the range over the time period covered. The idea behind is that prices tend to close near the extremes of the recent range before turning points. Traditionally, Stochastic Oscillator readings greater than the 80 level are considered to be in an overbought territory (Bearish signal), whereas readings lower than the 20 level are considered to be in an oversold territory (Bullish signal).
Mathematically, the stochastic oscillator (%K) is calculated by the following formula.
$$\% K(N1,N2) = \frac{{\sum\limits_{i = 0}^{N2} {[P_{t - i} - LL_{t - i} \, ({\text{N}}1)]} }}{{\sum\limits_{i = 0}^{N2} {[HH_{t - i} \, ({\text{N}}1) - LL_{t - i} \, ({\text{N}}1)]} }} \times 100$$
P
t
is the closing price at time “t”, LL(N1) is the lowest low price of previous N1-period, HH(N1) is the highest high price of previous N1-period and N2 is the averaging period of %K.
The standard values for “Ns” are 5 days (N1) and 1 day (N2) (Colby 2003). This paper also searches for optimal parameter values and then compares results with that from standard parameters.
The buy signal to enter a long position (or to cover a prior short position) is generated when the stochastic oscillator is in an oversold territory (%K < 20). On the other hand, the sell signal to enter a short position (or to close a prior long position) is generated when it is in an overbought territory (%K > 80).
This paper also tests another variant of a trading rule based on STOCH. Basically, instead of using a fixed band, the buy signal is generated when %K line crosses above %D line (moving averages of %K), while the sell signal is generated when %K line crosses below %D line. Let us call this trading rule “stochastic oscillator crossing its own moving average” (STOCH-D).
Mathematically, the moving average (%D) of stochastic oscillator (%K) is calculated by the following formula.
$$\% D = EMA\;[\% K(N1,N2),N3]$$
N3 is the averaging period of %D. EMA stands for exponential moving average.
The standard values for “Ns” are 5 days (N1), 1 day (N2) and 3 days (N3) (Colby 2003). Again, we also search for optimal parameter values and then compare results with that from standard parameters.
Moving Average Convergence-Divergence (MACD)
The MACD is a difference between two exponential moving averages (EMA) of the closing price. A slower EMA is subtracted from a faster EMA. Then the MACD itself is smoothed again with an even faster EMA to get the MACD’s Signal Line. The difference between MACD and MACD’s Signal Line is a MACD’s Histogram.
To calculate MACD, first we must calculate EMA of close prices. Generally, we write EMA as a function of N Periods. For example, EMA (P,N) means the exponential moving averages of close prices (P) over N days.
Mathematically, the EMA is calculated by the following equation.
$$\begin{aligned} &EMA_{t} = EMA_{t - 1} + \alpha (P_{t} - EMA_{t - 1} ) = \alpha P_{t} + (1 - \alpha )EMA_{t - 1} \hfill \\ & \alpha = \frac{2}{(N + 1)} \hfill \\ \end{aligned}$$
P
t
is the closing price at time “t”, N is the number of days and EMA stands for exponential moving average. α is the weight given to the most recent observation. Basically, it is a smoothing factor (the lower, the smoother EMA). 1 – α is the weight given to the latest smoothed variable.
We start the recursion by setting EMA1 = SMA(P,N), which is a simple average of close prices over N days.
The smoothing factor (\(\alpha\)) is chosen so as to give the same “average age” of the data as that of a simple moving average (SMA). An “average age” is the amount of time by which moving averages will tend to lag behind turning points in the original data. The “average age” in this case is (N − 1)/2.
Mathematically, the formulas for MACD and its signal line are the following.
$$\begin{aligned} MACD = EMA(P,N1) - EMA(P,{\text N2}),{\text{ where N1}} \, < \,{\text {N2}} \hfill \\ {\text{Signal}} - MACD = EMA(MACD,N3) \hfill \\ \end{aligned}$$
P
t
is the closing price at time t, N is the number of days and EMA stands for exponential moving average.
The standard values for “Ns” are 12 days (N1), 26 days (N2) and 9 days (N3) (Colby 2003). This paper also searches for optimal parameter values and then compares results with that from standard parameters.
The buy signal to enter a long position (or to cover a prior short position) is generated when the MACD crosses above its own Signal Line (Bullish signal). On the other hand, the sell signal to enter a short position (or to close a prior long position) is generated when the MACD crosses below its own Signal Line (Bearish signal).
Directional Movement Indicator (DMI)
The DMI is a filtered momentum or trend-following indicator. Fundamentally, it is a directional movement measure standardized by volatility. The DMI is designed to give buy or sell signal only when a market shows significant trending characteristics to avoid unprofitable trades by following a non-existing trend during a sideways market (Wilder 1978). When a market exhibit no trending behavior, the DMI would tell investors to keep out of the market.
Wilder (1978) also introduces Average Directional Movement Index (ADX) as a measure of trend strength. The buy or sell signals are generated from the DMI only if the ADX indicates that there is a strong trend.
Computationally, both DMI and ADX are calculated in the following steps.
-
1.
Calculate a measure of volatility called True Rang (TR).
$${\text{TR}} = {\text{Max}}\left[ {|{\text{High}} - {\text{Low}}\left| {, \, } \right|{\text{High}} - {\text{Previous Close}}\left| {, \, } \right|{\text{Low}} - {\text{Previous Close}}|} \right]$$
-
2.
Calculate average true range [ATR(N1)] by summing TR over N1 days. Then, perform a Wilder’s smoothing over TR(N1) by using the following formulas.
$${\text{First ATR}}\left( {\text{N1}} \right) = {\text{Sum of the first N1 periods of TR}}$$
$${\text{Subsequent ATR}}\left( {\text{N1}} \right) = {\text{Prior ATR}}\left( {\text{N1}} \right){-}\left[ {{\text{Prior ATR}}\left( {\text{N1}} \right)/{\text{N1}}} \right] + {\text{Current TR}}$$
-
3.
Calculate UpMove and DownMove with the following formulas.
$${\text{UpMove}} = {\text{today}}'{\text{s Hight}}{-}{\text{yesterday}}'{\text{s High}}$$
$${\text{DownMove}} = {\text{yesterday}}'{\text{s Low}}{-}{\text{today}}'{\text{s Low}}$$
-
4.
Calculate directional movement (DM) with the following formulas.
$$\begin{aligned} {\text{If UpMove}} > 0{\text{ and UpMove}} > {\text{DownMove}}, \hfill \\ \;{\text{then }} + {\text{DM}} = {\text{UpMove}},{\text{ Else }} + {\text{DM}} = 0. \hfill \\ \end{aligned}$$
$$\begin{aligned} {\text{If DownMove}} > 0{\text{ and DownMove}} > {\text{UpMove}}. \hfill \\ {\text{then }} - {\text{DM}} = {\text{DownMove}},{\text{ Else }} - {\text{DM}} = 0. \hfill \\ \end{aligned}$$
-
5.
Calculate DM(N1) by summing DM over N1 days. Then, perform a Wilder’s smoothing over DM (N1) by using the following formulas.
$${\text{First DM}}\left( {\text{N1}} \right) = {\text{Sum of the first N1 periods of DM}}$$
$${\text{Subsequent DM}}\left( {\text{N1}} \right) = {\text{Prior DM }}\left( {\text{N1}} \right){-}\left[ {{\text{Prior DM}}\left( {\text{N1}} \right)/{\text{N1}}} \right] + {\text{Current DM}}.$$
-
6.
Calculate Directional Movement Indicator (DMI), which is a standardized DM over a period of N1 days. It is standardized by a volatility measure called ATR(N1).
Positive Directional Indicator (PDI)
$${\text{PDI}}\left( {\text{N1}} \right) = \left[ { + {\text{DM}}\left( {\text{N1}} \right)} \right]/\left[ {{\text{ATR}}\left( {\text{N1}} \right)} \right] \times 100$$
Minus Directional Indicator (MDI)
$${\text{MDI}}\left( {\text{N1}} \right) = \left[ { - {\text{DM}}\left( {\text{N1}} \right)} \right]/\left[ {{\text{ATR}}\left( {\text{N1}} \right)} \right] \, \times { 1}00.$$
-
7.
Calculate Directional Movement Index (DX). It measures the trend strength of each day based on a price pattern over previous N1 days. Unlike DMI, it does not indicate any price movement directions.
$${\text{DX}}\left( {\text{N1}} \right) = \frac{{\left| {{\text{PDI}}\left( {\text{N1}} \right)){-}{\text{MMI}}\left( {\text{N1}} \right))} \right|}}{{\left( {{\text{PDI}}\left( {\text{N1}} \right) + {\text{MDI}}\left( {\text{N1}} \right)} \right)}} \times 100$$
-
8.
Calculate average Directional Movement over N1 days [ADX(N1)] by performing a Wilder’s smoothing over DX with the following formulas.
$${\text{First ADX}}\left( {\text{N1}} \right) = {\text{Simple average of first N1 periods of DX}}\left( {\text{N1}} \right).$$
$${\text{Subsequent ADX}}\left( {\text{N1}} \right) = \left[ {{\text{Previous ADX}}\left( {\text{N1}} \right)} \right]{\text{x}}\left( {{\text{N1}} - 1} \right) + {\text{Current DX}}\left( {\text{N1}} \right)/{\text{N1}}.$$
-
9.
Calculate average directional movement rating (ADXR) as the simple average of today’s ADX and ADX of N1 days ago.
The ADX does not indicate trend direction or momentum. It only measures trend strength. It is a lagging indicator in a sense that a trend must have established firmly before the ADX will generate a signal that a trend is under way. The ADX varies between 0 and 100. Generally, ADX readings below 20 indicate trend weakness and readings above 40 and 50 indicate a strong trend and an extremely strong trend, respectively. However, one major problem with the ADX is that it is too volatile. The ADXR improves over the ADX on this respect by using the average instead of a single number. In general, ADXR less than 20 indicates a trendless market, while ADXR greater than 25 indicates a trending market.
The standard value for “N1” is 14 days (Colby 2003). This paper also searches for optimal parameter values and then compares results with that from standard parameters.
The buy signal to enter long position is generated when PDI(N1) > MDI(N1) and ADXR > 25 and the position is reversed when PDI(N1) < MDI(N1) or ADXR < 25. On the other hand, the sell signal to enter short position is generated when MDI(N1) > PDI(N1) and ADXR > 25 and the position is reversed when MDI(N1) < PDI(N1) or ADXR < 25.
On Balance Volume (OBV)
The OBV is a volume-based indicator that relates volume to price change. Basically, it is a running total of volume. If a closing price today is higher (lower) than a closing price yesterday, then the entire today’s volume will be added (deducted) to (from) the previous day OBV to get today OBV. It does not matter how much the price changes. Only the direction of price change matters.
The underlying assumption is that OBV changes precede price changes. The reason is that smart money (investment made by well-informed and sophisticated investors) are flowing into the stock, reflecting in a rising OBV. When the public starts to follow, both the stock price and OBV will surge even more.
The buy signal to enter long position (or to cover prior short position) is generated when the OBV line crosses above its own N1-day EMA (Bullish signal). On the other hand, the sell signal to enter short position (or to close prior long position) is generated when the OBV line crosses below its own N1-day EMA (Bearish signal).
The standard value for “N1” is 3 days (Colby 2003). This paper also searches for optimal parameter values and then compares results with that from standard parameters.