Sharing investing and trading ideas. Helping traders get started.
Advertisement

Friday, May 4, 2012

Directional Movement - Backtest Results and Implementation Issues

Directional Movement - Backtest Results and Implementation Issues
Discusses basic issues and results when attempting to back-test the Directional Movement formula.

Data: S&P500 Emini Futures
Futures Contract Rollover: Arbitrarily set on second Friday of every Mar, Jun, Sep and Dec
Period: 28 Dec 2008 - 31 Mar 2012 (Hourly Chart)
VBA Code: Method B of Code
Excel Version: 2010

Note: 1) As with the Aroon Indicator, the Directional Movement can be used for other time frames and not necessarily daily data as is the context when I wrote the Directional Movement explanation page.

2) The directional movement indicator refers to an implementation of the directional movement formula. What this page attempts to do is to backtest the directional movement formula, not the directional movement index and also not the directional movement indicator. Return to the technical analysis page for links to the respective indicators, codes and backtest results. 

Click here for background information, formula, calculation steps and the entire VBA code.

There are multiple variations on how to apply an indicator. I seek your understanding that the work done below are experiments and are for information purposes only.

Results Summary
Divergence does not signify that a trend is forming in the hourly charts based on my dataset. I inverted this trading rule and arrived with a strategy that is profitable before transaction costs, as expected. Given the large number of trades generated, the naive trading rule applied will most likely not be profitable after costs. The interesting fact is that this is the second or third indicator I found where the  usual trading rule I read from other sources has to be inverted in order for the strategy to even show before transaction cost profitability.

Procedure in Brief
Pasted the code into Excel with changes made as per comments in code to direct application to ranges with input data (High, Low, Close columns). Screen Shot 1 shows the output (the last four columns).

Screen Shot 1
Detailed Findings and Results

Summary of Trading Rules -

1) Calculate Positive DM Minus Negative DM. Recall that Negative DM is a positive value. Negative refers to the fact that a new low was created in the current bar. 
2) If (Positive DM Minus Negative DM) is greater than 0, Long 
3) If (Positive DM Minus Negative DM) is lower than 0, Short
4) Else maintain long or short position

517 index points of profit (before transaction costs) were generated on a large set of 6,687 trades. Average return is very small at just 0.08 points per trade, which means that such an application will not cover trading costs for most people (I guess?). 59% of trades were profitable. Standard deviation of returns for each trade is 4.93 points. The profit trajectory of this indicator and trading rules is shown in Chart 1. 

Chart 1: Cumulative Profit of Strategy (Before Costs)
Conclusion
Although this application of the DM generated a lot of trades, just like my attempt with the Aroon Indicator, the trading rule in this case did not generate statistically significant profitability based on the student t statistic. The low per trade profitability of this approach negated the statistical effect of a large number of trades in reducing standard error. I end this post at this juncture as we will be using this Directional Movement formula in various forms when backtesting the directional movement index and the directional movement indicator. More can be elaborated then. 

Any suggestions or comments are welcome. 


Like what you have just read? Digg it or Tip'd it.
The objective of Finance4Traders is to help traders get started by bringing them unbiased research and ideas. Since late 2005, I have been developing trading strategies on a personal basis. Not all of these models are suitable for me, but other investors or traders might find them useful. After all, people have different investment/trading goals and habits. Thus, Finance4Traders becomes a convenient platform to disseminate my work...(Read more about Finance4Traders)

Tuesday, May 1, 2012

Aroon Indicator / Oscillator - Backtest Results and Implementation Issues

Aroon Indicator / Oscillator AI / AO - Backtest Results and Implementation Issues 
Discusses basic issues and results when attempting to back-test the AI and the AO indicators

Data: S&P500 Emini Futures
Futures Contract Rollover: Arbitrarily set on second Friday of every Mar, Jun, Sep and Dec
Period: 28 Dec 2008 - 31 Mar 2012 (Hourly Chart)
VBA Code: Method B of Code
Excel Version: 2010

Note: When I wrote the post for the Aroon Indicator VBA code, I wrote it in the context as though the Aroon Indicator and Oscillator can only be used on a daily basis. This is not necessarily always the case. In this case, I used the Aroon Indicator on the same hourly data as with all other backtests. 

Click here for background information, formula, calculation steps and the entire VBA code.

There are multiple variations on how to apply an indicator. I seek your understanding that the work done below are experiments and are for information purposes only.

Summary of Results 
While the Aroon Indicator has been described as a "trend" type indicator, I found that it behaves more as a price reversion indicator in the context of hourly data. Like the adaptive price zone (APZ) indicator, commonly known applications of the Aroon Indicator turned out to be loss making, requiring an inversion of the trading rule. While the Aroon Indicator (and the final trading rules used) is profitable before transaction costs, the key challenge lies with tweaking it to be profitable AFTER costs. Average profit per trade is only 0.2 index points per trade. 

Procedure in Brief
Pasted the code into Excel with changes made as per comments in code to direct application to ranges with input data (High, Low, Close columns). Screen Shot 1 shows the output (the last two columns).  

Screen Shot 1

Detailed Findings and Results
Period is set at 5 - This means that the formula looks at only the last five hours of data in the calculation of current hour Aroon Indicator value.

Summary of Trading Rules -

1) If Aroon Up is larger than Aroon Down at the end of each hour, SHORT in the next hour
2) If Aroon Down is larger than Aroon Up at the end of each hour, LONG in the next hour.
3) Otherwise, carry forward previous hour's position.

This set of trading rules generated 869.5 index points of profit (before transaction costs) on a large set of 4,146 trades. Average return per trade is 0.210 points on a standard deviation of 6.328 points. The success rate of this strategy is very high. 63.9% of the trades were profitable (before transaction costs and slippage). The profit trajectory of this indicator and trading rules is shown in Chart 1.

Chart 1: Aroon Indicator Cumulative Profit (Before Costs)

Conclusion
This set of trading rules and the indicator used generated a lot of trades. As a result, the standard error of the mean return is very small due to the formula used, which is standard deviation of returns of each trade divided by the number of trades. In turn, standard statistical distributions, such as the student t-statistic and normal z-statistic are significant when computed for this strategy. 

However, I have my doubts over the significance of these statistics. Due to the long tail nature of financial data, standard distributions may not correctly present the distribution of the returns of this strategy. Maybe this statistical significance will disappear when the correct statistic is used. 

Furthermore, I have repeatedly emphasized that the returns I calculated exclude commissions and slippage. I believe that this naive strategy on its own may not be profitable once I incorporate these costs.

The Aroon Oscillator measures the difference between the Aroon Up and Aroon Down indicator. As such, my trading rules are a form of the application of the Aroon Oscillator. 

Further research, in my opinion, can be in the application of these naive trading rules to larger time frames, e.g. daily, half-daily charts, which are more likely to generate less trades and lower trading costs. However, at larger time frames, the behaviour between price movements and the Aroon Indicator may change and may require the trading rules to be adjusted.

Any suggestions or comments are welcome.



Like what you have just read? Digg it or Tip'd it.
The objective of Finance4Traders is to help traders get started by bringing them unbiased research and ideas. Since late 2005, I have been developing trading strategies on a personal basis. Not all of these models are suitable for me, but other investors or traders might find them useful. After all, people have different investment/trading goals and habits. Thus, Finance4Traders becomes a convenient platform to disseminate my work...(Read more about Finance4Traders)

Sunday, April 29, 2012

Adaptive Price Zone APZ - Backtest Results and Implementation Issues

Adaptive Price Zone APZ - Backtest Results and Implementation Issues 

Discusses basic issues and results when attempting to back-test the APZ indicator

Data: S&P500 Emini Futures
Futures Contract Rollover: Arbitrarily set on second Friday of every Mar, Jun, Sep and Dec
Period: 28 Dec 2008 - 31 Mar 2012 (Hourly Chart)
VBA Code: Method B of Code
Excel Version: 2010

Click here for background information, formula, calculation steps and the entire VBA code.

There are multiple variations on how to apply an indicator. I seek your understanding that the work done below are experiments and are for information purposes only.

Summary of Results 
Conventional application of the APZ (i.e. long at the lower boundary and short at the upper boundary in anticipation of price reversal) is found to be not profitable. However, the reverse is somewhat profitable (long when price exceeds upper boundary of APZ and vice versa), suggesting that this technical indicator and the applied trading rules have potential for real-life implementation with further tweaking to the application method (e.g. chart indicator based on hourly data, but trades are generated as and when the trading rules are met subsequently). 

Procedure in Brief
Pasted the code into Excel with changes made as per comments in code to direct application to ranges with input data (High, Low, Close columns). Screen Shot 1 shows the output (the last seven columns). The first value of some columns are error values as their formulas include reference to cells on the first row which are actually text headings, not numbers. However, calculations in subsequent rows are unaffected. 

Screen Shot 1

Detailed Findings and Results
Inputs - Band factor is set at 2, EMA period is set at 5

Summary of Trading Rules -

1) If Close at this hour is higher than the APZ upper limit at the end of the last hour, enter long at the end of this hour
1) If Close at this hour is lower than the APZ lower limit at the end of the last hour, enter long at the end of this hour


223.25 index points of profit (before transaction costs) were generated out of this strategy on 344 trades. Average return per trade is 0.65 points on a standard deviation of 21.34 points. Therefore, this strategy does not look statistically profitable. The success rate of this strategy is 39%, i.e. only 135 trades were profitable. The profit trajectory of this indicator and strategy is shown in Chart 1. 

Chart 1: Cumulative Profit of APZ and Applied Trading Rules

Conclusion
Contemporary price behavior for the S&P500 suggests that the APZ is more suited for use as a "trend" type indicator, rather than a "price reversion" indicator as I have always thought. The key risk is that we cannot be certain that the behaviour of the APZ indicator versus the S&P500 will remain constant in the future. Under certain regimes, the APZ may behave as a price reversion indicator which would require the inversion of the above trading rules.

Further research can be in the application of this model in finer time granularity.

Any suggestions or comments are welcome.


Like what you have just read? Digg it or Tip'd it.
The objective of Finance4Traders is to help traders get started by bringing them unbiased research and ideas. Since late 2005, I have been developing trading strategies on a personal basis. Not all of these models are suitable for me, but other investors or traders might find them useful. After all, people have different investment/trading goals and habits. Thus, Finance4Traders becomes a convenient platform to disseminate my work...(Read more about Finance4Traders)

Saturday, April 28, 2012

Accumulation/Distribution Line ADL - Backtest Results and Implementation Issues

Accumulation/Distribution Line (ADL) - Backtest Results and Implementation Issues
Discusses basic issues and results when attempting to back-test the ADL line indicator

Data: S&P500 Emini Futures
Futures Contract Rollover: Arbitrarily set on second Friday of every Mar, Jun, Sep and Dec
Period: 28 Dec 2008 - 31 Mar 2012 (Hourly Chart)
VBA Code: Method B of Code
Excel Version: 2010

Click here for background information, formula, calculation steps and the entire VBA code.

There are multiple variations on how to apply an indicator. I seek your understanding that the work done below are experiments and are for information purposes only.

Summary of Results 
A naive strategy produced profitable results without accounting for transactions costs. Further research is necessary to create expected returns that remain positive after trading costs.

Procedure in Brief
Pasted the code into Excel with changes made as per comments in code to direct application to ranges with input data (High, Low, Close columns). Screen Shot 1 shows the output (the last three columns)

Screen Shot 1

Detailed Findings and Results
1) Conventional implementations of the ADL line suggests that divergence between ADL and prices are meaningful. However, it is difficult to judge divergence based on indicator and price levels alone. 

In my sample period, the ADL line, like price data, is non-stationary. Simply put, the ADL does not fluctuate around a constant mean. Otherwise, I simply did not use enough data to demonstrate the stationarity of the ADL line. Therefore, the ADL line in its raw form may not be easy to interpret. 

Chart 1: ADL line versus S&P 500

2) I tried rescaling the data using the formula -

Adjusted Close = (Close - Low of entire period) / (High of entire period - Low of entire period)
Adjusted ADL = (ADL - ADL Low of entire period) / (ADL High of entire period - ADL Low of entire period)
Chart 2 shows how the rescaled data looks like

Chart 2

Again, there is no meaningful interpretation at first glance. Furthermore, in real life implementation, there is no way of knowing the low and high of the entire period, including past, current and future moments in time.

3) Finally, I resorted to measuring the change in

I used the following simple trading rule

A) Calculate the percentage change in price at the end of each hour
B) Calculate the percentage change in ADL at the end of each hour
C) Calculate Percentage Change in ADL - Percentage Change in Price
D) If Percentage Change in ADL is higher than Percentage Change in Price, Long (in the next hour)
E) If Percentage Change in ADL is lower than Percentage Change in Price, Short (in the next hour)
F) If Percentage Change in ADL is equal to Percentage Change in Price, Maintain Position (in the next hour)

Conclusion
Unadjusted for slippage and transaction costs, my simple trading rule above generated 9,838 trades over a three year plus period and 601 index points per contract of profit. Chart 3 shows the cumulative profit of this strategy (without transaction costs).

Chart 3: Cumulative Gross Profit

However, the sure number of trades suggest that transaction costs will be high. As such, practical implementation will be a challenge. The breakeven level requires each trade to have a transaction cost of at most 0.061 index points (601 divided by 9838).

Further research can be in the modification of trading rules, such as enter into a long or short position only if the positive or negative divergences are sufficiently large.

Any suggestion or comments are welcome.



Like what you have just read? Digg it or Tip'd it.
The objective of Finance4Traders is to help traders get started by bringing them unbiased research and ideas. Since late 2005, I have been developing trading strategies on a personal basis. Not all of these models are suitable for me, but other investors or traders might find them useful. After all, people have different investment/trading goals and habits. Thus, Finance4Traders becomes a convenient platform to disseminate my work...(Read more about Finance4Traders)