Tuesday, June 16, 2015
Mehul Dhikonia InfoTrie
This document studies financial technical indicators and compares Forex investment strategies based on these indicators over historical data.
Currently, this report features only the following two indicators:
- Moving Average Convergence and Divergence (MACD)
- Relative Strength Index (RSI)
- Stochastic Momentum Index (SMI)
Moving Average Convergence and Divergence (MACD)
MACD is a trailing momentum indicator that shows the difference between two moving averages of asset prices. It is supposed to reveal changes in the strength, direction, momentum, and duration of a trend in a stock’s price.
The MACD is optimally calculated by subtracting the 26-day exponential moving average (EMA) from the 12-day EMA. A nine-day EMA of the MACD called the “signal line”, is then plotted on top of the MACD, functioning as a trigger for buy and sell signals.
There MACD may be interpreted in multiple formats, the most common of which are:
Signal Line Crossovers
Signal line crossovers are the most common MACD signals. The MACD values are compared to signal line while interpreting signal line crossovers.
A bullish crossover occurs when the MACD turns up and crosses the signal line. A bearish crossover occurs when the MACD turns down and crosses the signal line. Crossovers can last a few days or a few weeks, it all depends on the strength of the move.
Centre Line Crossovers
A center line crossover occurs when the MACD series changes sign, that is, the MACD line crosses the horizontal zero axis. A bullish centerline crossover occurs when the MACD Line moves above the zero line to turn positive. A bearish centerline crossover occurs when the MACD moves below the zero line to turn negative.
A bullish divergence occurs when the price makes a new low but the MACD does not confirm with a new low of its own. A bearish divergence occurs when the price makes a new high but the MACD does not confirm with a new high of its own.
Consider the following plot showing showing derivative prices alongside MACD values:
Relative Strength Index (RSI)
This index is is intended to chart the current and historical strength or weakness of a stock or market based on the closing prices of a recent trading period. A technical momentum indicator that compares the magnitude of recent gains to recent losses in an attempt to determine overbought and oversold conditions of an asset. It is calculated using the following formula:
The RSI chart ranges from 0 to 100. An asset is deemed to be overbought once the RSI approaches the 70 level, meaning that it may be getting overvalued and is a good candidate for a pullback. Likewise, if the RSI approaches 30, it is an indication that the asset may be getting oversold and therefore likely to become undervalued.
The following plot charts RSI values computed over a period of 14 days.
Stochastic Momentum Index (SMI)
SMI helps you see where the current close has taken place relative to the midpoint of the recent high to low range is based on price change in relation to the range of the price. The index oscillates between -100 to 100, where negative values suggest closing point of a particular day falls below mid point of high low range and vice versa. As in the case of MACD and RSI indices SMI can be interpreted in more than one dimension.
The following chart depicts SMI scores as observed alongside USDEUR spot prices.
The popular overbought/oversold levels for the SMI index are +40/-40. Blindly trading off overbought or oversold signals can be dangerous unless we recognize clear support and resistance for the underlying equity or using a confirmation window/zone to validate the signal.
Signal Line Crossovers
This is similar to signal line crossovers as discussed in MACD. As the number of signal line crossovers are generally frequent it may result in a lower number of correct predictions. To counter this one may filter out lower probability crossovers by using a neutral zone +/-15. The concept of neutral zone provides a window where in we don’t act on a crossover immediately (when it occurs in +15/-15 range) but rather wait for the trend to develop.
Therefore, if you entered a buy trade based on an SMI crossover at -40 or less and then you notice a crossover in the +/- 15 neutral zone, you would not reverse the position but rather watch how the market reacts to relative support on the current move higher. If the market moves nicely through the neutral zone with the trend in tact then you can tighten your stops or add to your trade if you wish.
Divergence is not very common but serves as an effective signal when generated. Divergence happens when prices are making higher highs and the SMI is not. This can happen on the sell side when the price is making lower lows and the SMI is not which would give you an opposing buy signal when price breaks relative resistance.
Commodity Channel Index (CCI)
In general, CCI measures the current price level relative to an average price level over a given period of time. CCI is relatively high when prices are far above their average. CCI is relatively low when prices are far below their average. In this manner, CCI can be used to identify overbought and oversold levels.
The CCI is calculated as the difference between the typical price of a commodity and its simple moving average, divided by the mean absolute deviation of the typical price. The index is usually scaled by an inverse factor of 0.015 to ensure that approximately 70 to 80 percent of CCI values would fall between ???100 and +100:
CCI may be used as a coincident or a leading indicator. As a coincident indicator, we look for overbought/oversold levels; surges above/below 100/-100 can be used as sell/buy signals. Bearish and Bullish divergences may be seen as a leading indicator.
Conceptually, oversold/overbought levels are similar to as explained in the case of RSI indicator. Simply the oversold/overbought levels change. The concept of Divergence is also similar to as explained with relation to SMI.
The following chart depicts CCI scores as observed alongside USDEUR spot prices
Chande Momentum Oscillator (CMO)
The CMO is similar to the Relative Strength Index (RSI) momentum oscillator. Unlike the RSI, calculations are based on data that has not been smoothed meaning extreme short-term movements are not hidden, so the indicator reaches overbought and oversold extremes more frequently. The scale for the CMO is bounded between +100 and -100 with the zero level being the equilibrium point between periods with positive momentum (>0) and periods with negative momentum (<0).
It is calculated as:
Overbought/oversold levels can be established at +50/-50 though as usual it is advised to use a signal confirmation by waiting for the trend to develop. Crossovers below +25 and above -25 can serve as a sell/buy confirmation signals.
The principle of divergence remains the same. Following chart shows CMO movement alongside USDEUR time series.
Backtesting Investment Strategies
For the purpose of backtesting and providing a broader picture, we consider the following two currency pairs: 1. USD/EUR, 2014-01-01 to 2015-04-28 2. USD/CHF, 2013-01-01 to 2014-01-01
These examples provide encompass different trend scenarios as USD/EUR pair displays a visible strong uptrend over the given time domain while USD/CHF pair provides a volatile sideways scenario. ### Baseline Strategy
Our baseline strategy revolves around a simple buy and holds strategy for the entire time domain. The returns obtained here would serve as a basis to test strategies based on MACD and RSI indices.
For the first example (USDEUR) the following R code and plots provide a summary for the baseline strategy:
With cumulative returns of ~26%, as shown above, our goal is to primarily beat this value.
For the second example (USD/CHF), we have
With considerable losses, we definitely want to perform significantly better than this.
MACD – Signal Line Crossover
In this strategy signal line crossover is interpreted as Buy (Bullish) signal when crosses over the signal line and Sell (Bearish) or short signal when it falls below the signal line.
Along these lines, we also devise a stop loss signal that helps us exit our current long or short position if losses are more than 0.5% for any given day.
The previous codes can be further expanded as follows to evaluate this strategy and generate a summary
For USD/EUR pair we see that cumulative returns obtained using Long strategy (with and without stop loss) are at around ~12% mark, far lower than the baseline strategy. This can be attributed to the fact that MACD is a trailing indicator and thus bullish and bearish trends loose steam by the time buy or sell signal are generated. Results are also below par if we consider a Long-Short strategy.
These results point out that MACD signal line crossovers shall not be solely considered for entry and exit decisions. The results for the USD/CHF pair are obtained as follows. You would see that Long Short strategy (with stop loss criteria) does offer a significant improvement over the baseline strategy but we do wish to perform better than 6% cumulative returns.
We compute our RSI index using 14-day exponential moving averages and the trading signals are generated as:
- Buy or long signal is generated when RSI moves above 30 marks and crosses an oversold threshold of 40.
- A sell signal is generated when RSI falls below 70 marks and crosses the overbought threshold of 60.
- An entry signal is also generated when RSI values are lurking in mid range (40-60) and crosses the 60 mark, indicating an uptrend. The intuition behind this entry point is that the underlying security is resisting uptrend and breaks out as RSI goes above the 60 mark.
The following code may be used to derive the results:
At ~19% cumulative returns for USD/EUR pair using RSI strategy is slightly better than MACD Signal crossover strategy but below par, if compared to baseline strategy. Again pointing out to the fact that no single indicator can cover the entire derivable technical information.
While for the USD/CHF pair the RSI offers no improvement over the baseline strategy as cumulative returns stay negative as seen in the following plot.
MACD and RSI
The previous two strategies can be combined to generate new signals that complement each other. The process simply involves taking a logical AND of the preceding signals. It can be seen as a logical elimination of false signals as observed in both cases, an implication of this may be the limited number of trading signals though with a higher accuracy.
The following summaries are obtained for USD/EUR and USD/CHF pairs. At ~13% cumulative returns on USD/EUR this combined strategy though fails to beats the baseline buy and hold strategy but is more accurate in terms of accuracy of predictions. With respect to USD/CHF pair, this strategy scores a marginally positive cumulative return improving minutely upon the returns as obtained using RSI strategy with a better prediction ratio.
The success of this strategy can be attributed to the combined knowledge provided by MACD and RSI, which help jointly validate price trends.
The SMI scores are computed using the default period of 13 days with 2 day period for initial smoothing and 25 day period for double smoothing and a 9 day period for the signal line.
SMI Overbought/Oversold Levels
It simply depicts a trading strategy on overbought/oversold levels as discussed earlier. In the first step, we simply observe a direct approach of buying and selling at +/-40 levels respectively.
The previous R code snippet holds for USDEUR currency pair and can be easily re-evaluated for the pair USDCHF as shown in the following chart.
Overbought/oversold levels define a very raw strategy is ought to misinterpret strong trends as observed in both the charts above where we end up taking early exits.
As discussed earlier we can modify this strategy using a confirmation window wherein we observe asset price movement in a fixed zone of SMI values before taking any trading decisions. Under the following strategy, we only commit to overbought/oversold levels once the SMI values move below +30 or above -30 marks. Also, strong pullbacks to +/-30 SMI mark are interpreted as buy/sell signals respectively.
As observed in the performance plot above this strategy works quite well as compared to the previous strategy in a trending scenario though same performance is not reciprocated in the sideways volatile scenario as shown below.
Signal Line Crossovers
As discussed earlier the signals generated using crossovers are plenty and are subject to false swings. The following code snippet and performance charts reflect the same.
Overbought/Oversold and Signal Line Crossovers
To get the best of both approaches a combination of both indicators is tested against both our sample cases. The first entry point is defined by oversold SMI levels while subsequent trade signals take into account for signal line crossovers with a neutral zone of -15 to +15 SMI values. If we notice a crossover in the +/- 15 neutral zone, we do not reverse the position but rather watch how the market reacts to relative support on the current move higher/lower. The same is depicted in the code below followed by performance charts for both our test cases.
The dual strategy offers a minor improvement over other the base strategies for the USDEUR pair. Overbought/oversold levels help identify a trend while signal line crossovers help in evaluation and re-entry into the ongoing trend. The mixed strategy provides a decent run over USDCHF pair initially (unlike other strategies) but succumbs to generate losses with an unprecedented downward shift in asset prices.
SMI strategies perform specifically well on trending time series through performance over sideways time series can be improved merging SMI based indicators with other technical indicators. This also serves as our future area of interest.
Typically CCI values are computed on 20 day period but a smaller or bigger period can be used to address different concerns. A smaller period, say 10 day period would be more volatile and thus generate a large number of signals.
CCI Overbought/Oversold Levels
Using a simple overbought/oversold strategy for entry and exit points we are likely to miss out on strong uptrends and down trends. This is a recognized weakness of this strategy is also seen in the case of RSI. Still, for the purpose of testing it out the following code snippet depicts this strategy as implemented over USDEUR time series. Remember, the overbought/oversold levels, in this case, are +100/-100.
Notice the absence of frequent signals as speculated earlier given the case of a strong uptrend. We thus simply move on to using overbought/oversold levels with a confirmation zone allowing for positions of re-entry and exit.
For our examples crossover below 50 are considered confirmation of overbought level thus allowing us to sell where as crossover above -50 serve as confirmation for oversold levels, generating a buy signal. There might be instances where the crossovers are reversed before entering overbought/oversold region, in such cases, a double crossover 50 (Sequentially: below and above) allows for re-entry into long position and similarly a double crossover -50 (Sequentially: above and below) allows to prevent losses by generating a sell signal.
For the USDEUR pair, the strategy is encompassed as follows:
As shown above, this strategy offers a pretty decent return on initial investment. For a sideways trend as in the case of USDCHF pair, we are able to generate a positive result from the above strategy. The code snippet below also searches for instances of divergence (though it is not used to generate any signals). The data table finally generated can be used to assess the impact of divergence on the currency pair.
In the above scenario, we also plotted the output of the simple overbought/overbought strategy and found that in a sideways scenario it is at par with the confirmation strategy.
In terms of implementation, Chande Momentum Oscillator is quite similar to RSI and CCI indicators. Thus, avoiding the jargon we can simply proceed to the testing part. Note: As CMO oscillates between -100 and 100 our overbought/oversold values are +50/-50 respectively.
The following code snippet compares returns obtained on USDEUR pair using CMO as an indicator with additional divergence part.
We observe, using CMO as an indicator a confirmation strategy offers a massive improvement over the crude overbought/oversold strategy. If compared with CCI indicator CMO is not as successful. Now testing it for USDCHF pair we have:
As observed above CMO is not as versatile as CCI indicator especially using a confirmation zone, possibly because the trend has already matured before a confirmation is received.