## Sunday, January 31, 2010

### A method for optimizing parameters

Most trading systems have a number of parameters embedded, parameters such as the lookback period, the entry and exit thresholds, and so on. Readers of my blog (for e.g., here and here) and my book would know my opinion on parameter optimization: I am no big fan of it. This is because I believe financial time series is too non-stationary to allow one to say what was optimal in the backtest is necessarily optimal in the future. Most traders I know would rather trade a strategy that is insensitive to small changes in parameters, or alternatively, a "parameterless" strategy that is effectively an average of models with different parameters.

That being said, if you can only trade one model with one specific set of parameters, it is rational to ask how one can pick the best (optimal) set of parameters. Many trading models have a good number of parameters, and it is quite onerous to find the optimal values of all these parameters simultaneously. Recently, Ron Schoenberg published an article in the Futures Magazine that details a way to accomplish this with just a tiny amount of computer power.

The key technique that Ron uses is cubic polynomial fit of the P&L surface as a function of the parameters. Ron uses the VIX RSI strategy in Larry Connors' book "Short Term Trading Strategies That Work" as an example. This strategy has 5 parameters to be optimized, but Ron only needs to compute the P&L for 62 different sets of parameters, and the whole procedure only takes 58 seconds.

Although Ron has confirmed that most of the parameters that Connors picked are close to optimal, he did find a few surprises: namely, that RSI of period 3 or 4 is significantly more profitable than the 2 that Connors used, at least in the backtest period.

Now, for a true test of this optimization, it would be helpful if Ron performed this optimization withholding some out-of-sample data, and see if these parameters are still optimal in that withheld data set. Since he didn't do that, we need to wait for another year to find out ourselves!

## Tuesday, January 19, 2010

### Excel ADF test

Some readers have asked whether there is an Excel version of the ADF test for cointegration (mentioned in articles here or here.) You can download one such package here (Hat tip: Bruce H.).

And as always, you can download the Matlab version from spatial-econometrics.com.

## Saturday, January 09, 2010

### Does Averaging-In Work?

Ron Schoenberg and Al Corwin recently did some interesting research on the trading technique of "averaging-in". For e.g.:  Let's say you have \$4 to invest. If a future's price recently drops to \$2, though you expect it to eventually revert to \$3. Should you

A) buy 1 contract at \$2, and wait for the price to possibly drop to \$1 and then buy 2 more contracts (i.e. averaging-in); or
B) buy 2 contracts at \$2 each;  or
C) wait to possibly buy 4 contracts at \$1 each?

Let's assume that the probability of the price dropping to \$1 once you have reached \$2 is p. It is easy to see that the average profits of the 3 options are the following:
A) p*(1*\$1+2*\$2) + (1-p)*(1*\$1)=1+4p;
B) 2; and
C) p4*\$2=8p.

Profit A is lower than C when p > 1/4, and profit A is lower than profit C when p > 1/4. Hence, whatever p is,  either option B or C is more profitable than averaging in, and thus averaging-in can never be optimal.

From a backtest point of view, the Schoenberg-Corwin argument is impeccable, since we know what p is for the historical period. You might argue, however, that financial markets is not quite stationary, and in my example, if the historical value of p was less than 1/4, it is quite possible that the future value can be more than 1/4. This is why I never make too much effort to optimize parameters in general, and I can sympathize with traders who insist on averaging-in even in the face of this solid piece of research!