Message From TraderJanie
I not only love emails from my members, I covet them. I love talking to anyone who wants to know more about algo trading. So when I got an email from a member asking about optimizations I immediately started thinking, “If one asks this question, there are probably many more who are wondering about it.” Thus this newsletter is all about optimizing strategies.
Let’s say you’re Little Red Riding Hood and you need to get to Gramma’s house but you also need to elude “the Wolf.” You need to find the optimal route that will ensure all your home-baked goodies, you took hours preparing, get to Grammas. You also have to make sure that you are not eaten along the way. Since you don’t have algorithm aversion, you pull out your trusty GPS/Wolf Finder and plug in where you are at and where you need to go.
Voila, you make it to Grannie’s and circumvented the Wolf. You just optimized your route.
Whenever you find an optimal solution for doing anything in everyday life, you are actually performing implicit optimization.
Strategy optimization is searching for optimum parameters for the predefined criteria used to define the strategy that will get as close to your objective function as possible. Wow, that was a mouthful, heh? Stick with me, this will become clearer as you read on.
By testing a range of input values, the optimization process selects values that hopefully give you optimal strategy performance based on historical data. I’m sure you can fathom there are thousands of combinations that would take hours to test.
Let’s take an example – a very simple example. You want to test a simple crossover strategy. When the MA(8) is < the MA(13) then crosses above, and is now > the MA(13), you go long. When the MA(8) is above the MA(13) and crosses below, and is now < the MA(13) you go short.
Your parameters are the MA(8) and MA(13).
You test this strategy and the results give you the same dismal feeling as when you bite into a chocolate and find cherry flavored crème instead of the crunchy almonds you were expecting. You set out to find the crunchy almonds and begin your optimizing. You make the MA(8) and into MA(N) and the MA(13) becomes the MA(Z). When N < Z you’re short and when N > Z you’re long.
You run your optimizations on N and Z testing all the combinations between the two. Of course, you have to have upper (and sometimes lower) limits on the parameters or you’d have your computer on its knees begging to please rethink those parameters.
Strategy optimization is the search for the best parameters and the elimination of the bad ones. It goes without saying “best” and “bad” will have their own definitions.
Exhaustive optimization systematically goes through all potential combinations as it searches for the solution with the highest results for the criteria you choose. You can find inputs that maximize net income, minimize drawdown, or result in fewest trades.
The amount of time the exhaustive optimization feature needs to find the solution relates directly to the number of possible combinations it needs to test — the more combinations you have, the longer it will take. If only a few parameters are tested for a short range, this method is definitely optimal for finding the best inputs.
The first is a single numerical quantity or objective function to be maximized or minimized. The objective may be a company’s production costs or profits, the time of arrival of a vehicle at a specified destination, or the expected return on a stock portfolio.
The second element is a collection of variables, whose values can be manipulated to maximize the Objective Function. Examples include the amounts of various resources to be allocated to different production activities, the route to be followed by a vehicle (or Little Red Riding Hood) through a traffic network or values of the moving average – as in the example above.
The third element of optimization is a set of constraints, which are restrictions on the values that the variables can take. For instance, a manufacturing process cannot require more resources that are available, nor can it employ less than zero resources.
The constraints on the example above are the MA cannot be < 0 and should have an upper limit. As well, N has to be > Z when long and N has to < Z when short.
Optimization and Curve Fitting
Trading strategy development always involves optimization so some form of curve-fitting sneaks in as quietly as a husband coming home after a night of drinking with the guys.
Some claim that curve-fitting is as unavoidable as traffic on the interstate when trying to get home from work. Some claim curve-fitting is even necessary but others insist that any trading strategy that is curve-fitted will eventually fail.
I hope I get a ton of emails asking about over-optimizing. If I do, then I know I’m doing good work here.
We’re the Plan in “Plan your Trade and Trade your Plan” – TraderJanie
Sign up today