Some thoughts on optimization parameters
Author: avishn
Creation Date: 3/5/2010 4:33 PM
profile picture

avishn

#1
The following is inspired by Robert Pardo's book on optimization (http://www.amazon.com/Evaluation-Optimization-Trading-Strategies-Wiley/dp/0470128011) where he presents some thoughts about parameter step selection. He argues that you don't want to make the step too small (optimization would take a lot of time, especially if your strategy has several parameters), nor you want to make it too large (loss of optimization accuracy). That, and the fact that I had to wait for 2 hours until five-parameter strategy optimization is completed on my desktop, got me thinking...

Let's say we have a moving average period as one of the optimization parameters with a range of 10 to 100. Let's select 5 as the optimization step. That give us the following set of parameter values
CODE:
Please log in to see this code.

...total of 19 values

The problem is that while the absolute value of 5 represents a 50% increment at the parameter value of 10, it represents only a 5% increment at 100. So while we're obviously jumping over some possibly interesting parameter values at the beginning of the list, we end up churning through a lot of unnecessary small steps toward the end of it.

The fix to this problem is to make the parameter to slide over the logarithmic scale instead of the linear one. Instead of the fixed absolute step value we choose a uniform percent increment value.

First we need to estimate how many steps we need to cover the range
CODE:
Please log in to see this code.


For our example of the 10..100 range and the increment of 20% at each step it gives us 13 steps (12.6293 rounded up).

Next we create a simple parameter for our strategy with the range of 1..13 and step 1.

To find the value at each step we use this method ("val" being the step number 1 to 13):
CODE:
Please log in to see this code.


The resulting parameter value set looks like the following (values are rounded):
CODE:
Please log in to see this code.


In this set the absolute step value increases as we move from the beginning of the list to the end of it. This gives us (a) less parameter values to iterate over (12 vs 19) and (b) a uniform 20% step value increment so we're not losing accuracy at the beginning, nor making a lot of unnecessary iterations toward the end of the range.

Ideally something like this could've been added to the standard CreateParameter method in WealthScript. Because of the protection level of that method I was not able to find a way to create a library function suitable for Community.Components to wrap that method into, so I've ended up just implementing two helper methods above. Maybe Eugene or Cone can make an assessment if this is suitable/can be massaged into some form of a Community.Component method.
profile picture

Eugene

#2
Thank you, interesting share. Probably my memory needs to be refreshed, time to re-read some Pardo. But, speaking of MAs: doesn't it look that you're penalizing the upper range of optimizable values while overweighting the lower range at the same time?

Re: "wait for 2 hours until five-parameter strategy optimization is completed" -- we have something up our sleeve that will noticeably speed up optimizations. Not long to wait, I guess.
profile picture

Cone

#3
Agreed, interesting, and on the surface it makes sense. I haven't read Pardo, but an empirical test indicates to me that maybe you need to be selective for the indicators to which it is applied. For example, run the following scripts in 2 separate windows on GOOG Daily and tile them vertically.

CODE:
Please log in to see this code.

And separately this one -
CODE:
Please log in to see this code.

Now if you scale both charts semi-log, you'll find that the evenly-spaced moving average periods actually result in a more-evenly distributed averages. That's important because on a semi-log chart, the same vertical spacing represents the same percentage change no matter where you are on the scale.

Therefore, as Eugene points out, Pardo's method provides more resolution in the optimization space for the lower end of the range of periods, and that does not appear to be desirable for this test.
profile picture

Cone

#4
To save everyone time from running that test, here's what it looks like (note that the top script goes with the bottom image, and vice-versa).


profile picture

avishn

#5
These graphs give an interesting perspective at the problem. And I do agree that one needs to be selective when applying something like that to the strategy parameters. I guess one example when it would make sense to use it with SMA is when one uses "price closed above/below SMA" criteria to trigger or filter signals. In that case the first graph above obviously shows much higher resolution for the small (most interesting) values of the lookback parameter.

Intuitively, I guess my reasoning behind it is that in many, if not most, cases the parameter values are bound on one side. SMA lookback by definition cannot be less than one bar. On the other end of the range the lookback value is unbound (practical limitations aside). This is kind of similar to the prices themselves, that's why a semi-log scale works so well for the price chart. I have a strategy where one of parameters, a percentile of the price range, similar to Dr Koch's HiLoLimit, is bound on the right side (i.e. at 100%). The most interesting/profitable values are clustered right below 100% and the lower range limit is not that obvious (it can be 95% in one case and 50% in another). In that case I'm using negative percent (decrement) for the percentile parameter and it seems to work quite well. This would be an example when one needs more resolution at the higher end of the range.

As a side note, I guess it was not clear from my initial post... I didn't mean it that it was Pardo's book suggestion to use the log scale for parameters. It was rather my "creative interpretation" of the observations (fairly self-evident) he's made about the step/increment selection.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).