Using the Improved MA: Recent Feedback and further Instructions!

Posted on 28th December 2011 in Research

Hello and Merry Xmas!

We had been recently contacted by a reader of our blog who couldn’t find much difference using the IMA. The main question was that a simple (50, 200) EMA did the best on several indices.

The way IMA is constructed does not necessarily mean that IMA is always better to the usual MA indicator which is based on. However, if there is an active trader who constructs her strategy using MA rules (exclusively), our claim is that it is highly likely that she will be better off using the IMA backtesting all combinations.

Click here to download an .xlsx file as an example on SPY. The data was collected from Yahoo, starting from 2004-01-01 to 2011-12-22 using the code we have uploaded on our site. (click here for the code) (To keep thing simple, exit threshold is zero).

If someone is interested entirely on SMA, then she has to look at table 1 (only). In this table we see that IMA does not provide better results and the investor is better off using the MA cross-over rule with short MA = 50 days, long MA = 200 days. Please note that Sharpe in this case is 0.511 and Cumulative Return is 0.533.

Our suggestion is that the investor should not trust the SMA at all cases (or just one MA strategy). She should use backtesting and try different combinations for short and long MA periods as well as different MA methods (i.e. weighted MA, exponential MA etc). If we look at table 2, that provides the output for different EMA combinations, we see that the best strategy (across all tables) is the one based on the long EMA with 100 days. The Sharpe Ration here is 0.787 and the Cumulative Return is 0.733 (20% more!).

Hence, the above could be summarized in the following algorithm.

Using the Improved MA Criterion:

    • Set different combinations for short and long MAs (e.g. (k1,k2)={(10, 20), (20, 50), (20,100), (50,100), (20,200), (50,200), (100,200)} (or anything you find useful)
    • Use the above lengths in SMA, WMA, EMA and their Improved MA versions 
    • Compare their performance in backtesting (The choice of Exit Threshold is advised to be chosen using backtesting as well)

Then, it is highly likely (but not 100% guaranteed!) that the investor is better off using an Improved version of a criterion.

Here is the comparison.

 

  Simple MA (50,200)
                     
  Ret-MA1 Ret-MA2 Ret-MAC Ret-IMA1 Ret-IMA2 Ret-IMC Ret-IV1 Ret-IV2 Ret-IVC Ret-BnH
Average 0.041 0.037 0.061 0.051 0.010 -0.003 0.046 0.041 0.056 0.060
Volatility 0.107 0.105 0.119 0.107 0.062 0.012 0.105 0.101 0.116 0.220
Sharpe 0.380 0.350 0.511 0.471 0.165 -0.246 0.435 0.403 0.485 0.272
Max 0.040 0.044 0.047 0.044 0.026 0.010 0.040 0.044 0.047 0.145
Min -0.046 -0.039 -0.065 -0.048 -0.039 -0.030 -0.046 -0.039 -0.065 -0.098
Cumulative 0.322 0.283 0.533 0.428 0.068 -0.024 0.376 0.327 0.482 0.328
Drawdown 0.258 0.233 0.173 0.231 0.198 0.042 0.240 0.182 0.177 0.552
Duration 652 620 450 497 1119 635 507 587 460 1062
Profit/Loss 0.854 0.840 0.860 0.874 0.856 0.442 0.869 0.843 0.864 0.855
Win Rate 0.316 0.346 0.350 0.269 0.140 0.002 0.302 0.332 0.341 0.550
Expectation -0.414 -0.364 -0.349 -0.497 -0.741 -0.997 -0.437 -0.388 -0.364 0.020

 

  Exponential MA (20,100)
                     
  Ret-MA1 Ret-MA2 Ret-MAC Ret-IMA1 Ret-IMA2 Ret-IMC Ret-IV1 Ret-IV2 Ret-IVC Ret-BnH
Average -0.010 0.046 0.030 0.026 0.073 0.019 0.016 0.048 0.027 0.060
Volatility 0.123 0.107 0.111 0.103 0.093 0.059 0.117 0.104 0.100 0.220
Sharpe -0.077 0.430 0.268 0.254 0.787 0.316 0.133 0.460 0.270 0.272
Max 0.072 0.035 0.044 0.047 0.044 0.023 0.072 0.034 0.044 0.145
Min -0.089 -0.042 -0.047 -0.089 -0.042 -0.028 -0.089 -0.042 -0.039 -0.098
Cumulative -0.127 0.378 0.206 0.182 0.733 0.143 0.072 0.402 0.192 0.328
Drawdown 0.439 0.199 0.254 0.300 0.147 0.097 0.352 0.182 0.202 0.552
Duration 1151 561 544 909 527 1157 846 561 614 1062
Profit/Loss 0.832 0.860 0.825 0.871 0.890 0.926 0.871 0.859 0.804 0.855
Win Rate 0.315 0.348 0.348 0.250 0.279 0.116 0.295 0.335 0.313 0.550
Expectation -0.422 -0.353 -0.364 -0.532 -0.474 -0.777 -0.448 -0.377 -0.435 0.020

 

comments: 0 »

Waiting time to re-enter the market

Posted on 12th December 2011 in Research

(Fotis, Reason for Edit: Graphs)

 

Greetings to all,

 

I have been re-visiting the issue of the waiting time to re-enter the market, one a signal has been issued to exit from the current trade (e.g. when the current price drops below the entry price, in any of the two variations we have explored). Although in our code we have provided the option of a threshold parameter as a % of the entry price to fine-tune the exit strategy, we still have had questions about an approach that deals with “how many days should I wait before re-entering, if I do not want to wait until the next buy signal is issued and the standard moving average is still on?”

 

First, here is a reminder: if one looks at the price path itself then, once an exit signal is issued, the waiting time for a return to the origin (i.e. the last entry price) may be infinite – depending on certain assumptions underlying the nature of the random walk that prices follow. Therefore, once you exit you: (a) either wait for the next signal to re-enter or (b) you go short on the asset. How fast you exit is controlled by the threshold parameter.

 

Suppose now that instead of looking at the price we look at the intervals between signals, whether from the standard or the improved moving averages (in fact the following discussion applies to any signal variable). For concreteness consider the intervals you are out of the market and count the number of days per interval. Then, you generate a new time series of waiting times or durations which you can try to fit to an appropriate distribution. These durations correspond to the number of days you have to wait to have a new entry, whether this is issued by a new buy signal or be having the current price rise above the last entry price. It should be clear that the properties of such a series of waiting times is data and method dependent; however, can we draw some useful conclusions by modeling it?

 

The four figures below give a preview of some work-in-progress on this issue. They contain QQ plots of the durations for all 9 signals that our code returns benchmarked on the geometric distribution (which is suitable to this kind of analysis). Figures 1 and 1a are for SPY with the exponential and the weighted moving averages respectively, while Figures 2 and 2a are for EWJ again with the exponentiala and weighted moving averages. For both series the star date is 1993 and the look-back periods were 20 and 100 days; an exit threshold of 3% was also used.

 

The results show some consistencies that are surprising yet useful: (a) the fit of the geometric distribution is extremely good for both ETFs when the fast moving average is used, either in standard form or in the two improved forms (first vertical panel of three figures on the far left of each picture); (b) the fit decreases when we go to the slower moving average and decreases even more when we go to the moving average cross-overs; (c) the fit on (b) improves when we change from the exponential to the weighted moving average, again for both ETFs; (d) note that there appears to be a “kink” or discontinuity in the figures for the slower moving average and the moving average cross-over: this might imply that the waiting times cannot be modeled by a single probability in the geometric distribution but that probability might be dependent on the duration itself.

 

The above suggest two avenues of research that we are pursuing: first, how general is the result in (a) above and if it is how can we use it for more effective trading? For example, we could use the average waiting time implied by the geometric distribution to work out strategies for re-entry. Second, if the probability that determines re-entry depends on the duration itself how can we model it? I have made a modification to the standard geometric distribution that appears to be working and more results will be posted once we perform additional tests.

 

Hope you find this useful so please let us know of your thoughts.

comments: 0 »

Improved Moving Average using intra-day EUR/USD FOREX

Posted on 10th December 2011 in forex-bloggers, r-bloggers, Research

(Fotis, Reason for Edit: Sample Dates Added)

Hi everyone,

Here we present the graphical illustrations from two cases that our improved moving average method provides better results compared to the rest.

You can find the R-code here (is the same version).

In both cases we are using the Exponential Moving Average.  The figure on the left illustrates EMA(20,60) as fast and slow weights, whereas the figure on the right is using the ouput of an EMA(45,120).

Green line is the cumulative return using the method we suggest in the papers, red line is the method we suggest in the papers when once exit one can re-enter (as long as the current price is greater compared to the last entry price) , the black line is the cumulative return using the standard EMA and the blue line is the cumulative return of the Buy & Hold strategy. (for more information on how to read the graphs click here)

Here you can download the full set of experiment where we use a 0% exit threshold (as above), a 3% threshold and a 5% threshold.

If you want to see applications in more currencies or if you have in mind another couple of MA weights you ‘d like to see in action, reply to this post with your suggestions.

The exact number of trades for each method follows.

GDE Error: Unable to load profile settings

Download here the .pdfs with all figures.

EMA(20, 60) (9.6 MB)

EMA(45, 120) (9.4 MB)

 

The data is minute-by-minute, start on Oct. 20, 2012 at 09:00 and ends on Dec. 7, 2012 at 12:07. Sample size is 50482 observations. It was collected using Bloomberg Services.

I am thankful to the School of Economics and Finance, Queen Mary University of London, for providing me all the necessary tools needed for my research.

comments: 0 »

Sample of output from Ichimoku clouds

Posted on 9th December 2011 in Research

(Fotis, Reason for Edit: Graphs)

Greetings to all,

We are posting some output from a code that we are developing for Ichimoku clouds and their trading. This is a project for the near future but it would be nice to hear some opinions as to whether people are using them and to alert us if there is something in R for doing this – if there is we certainly missed it so please let us know.

The first figure uses the standard cloud terminology and has the standard settings of (9,26,52) days for constructing the various cloud lines.

The second figure has the settings (20,100,100) and we used those for a simple trading exercise (clearly the standard settings did not work with it). All figures are for SPY from 2000. Hope that you find this interesting.

 

comments: 0 »

Experiment and let us know!

Posted on 7th December 2011 in Research

Greetings to all,

Now that the code for the work in our first paper is uploaded it would be great if you test it with your own settings and share with everyone your results. The code has incorporated a number of additions that make backtesting easier and has been written with comments and explicit commands (rather than packages) to ensure portability to other applications that you have. The main features are as follows:

  • results for both price cross-overs and moving average cross-overs.
  • results for the standard moving averages, the improved moving average and a modified version of the improved moving average where, after an exit we re-enter once above the current entry price (i.e. we do not wait for a new signal).
  • there are options for three types of moving averages, simple, weighted and exponential.
  • there is an option for an exit threshold to reduce the number of exits that happen in the short-run.
  • results are returned ready to post-process and plot (they are aligned).
  • we provided a couple of additional functions that you could use.

We would be delighted to hear your opinion and results on the use of this material. We also would like to thank all of you that contributed to this project by so many constructive comments.

    comments: 0 »