Use of genetic optimisation in strategy design

Quantitative strategies always have parameters. Even in the trivial case we need to have at least one condition to enter and to exit a position — and in most cases such a condition will be based on a parameter: for example, “if price is greater than this value”, or “if this indicator is less than that value”. Of course ideally we’d prefer to know these values in advance — and sometimes it is possible. For example, if we design a strategy which trades breakouts above the historical high in stocks or index futures, then the value of such a breakout price level is known and cannot be modified. However in case of just a slightly more general breakout strategy — such as, a range breakout or a volatility breakout for instance — we immediately have a certain variability of values. Indeed, we can calculate the range as the highest and the lowest price between two time points, and these time points may differ. Or we can calculate it as a fraction of the volatility, and then question the value of this fraction — even set aside the very method used for calculating the very volatility. In all these cases we don’t have any exact values in the strategy logic — instead we have now parameters, or values which we can modify in order to maximise the strategy performance. The process of such a maximisation is typically called optimisation.

In the simplest case optimisation is done by consequentially iterating over all possible combinations of parameters’ values and then choosing the best performing one. In the example above we may choose to iterate over the points in time between which we calculate the entry range. While such a process, also know as exhaustive, or brute-force optimisation, is very straightforward and understandable, it has one remarkable drawback: with increased number of parameters the number of iterations grows in a geometrical progression. For example, if in our breakout strategy we expect the range to be formed in between 1 and 24 hours, then we should iterate both time parameters between 1 and 24, which (if we work with a data resolution of 1 hour) yields 24×24 = 576 possible combinations of parameters. And if we go down to 30-minute bars for greater precision, then we have 48*48 = 2304 combinations — and so forth. If we want to add other parameters, for example the limitation of the maximum breakout range, this will increase the number of iterations to tens and even hundreds of thousands, and sometimes to millions. Needless to say that even the fastest computers available to traders will work day and night for weeks to only calculate the performance for each of these millions of parameter combinations. And even if you are patient enough to wait, after this job is done there immediately appears another problem — how to analyse such a huge amount of information.

To solve this problem we may use two approaches. First, we could reduce the number of iterations consciously limiting the range of possible values of parameters. This is always the preferable way, as long as this limiting is understood and can be explained by a corresponding limitation in the market itself. For example, if we expect the breakout to happen only during working time, there’s not much sense in optimising the time across all 24 hours.

The second way to solve this problem is to use genetic optimisation. Without going into quite complex mathematical details, this is a method of dramatically reducing the total number of iterations in the optimisation loop by throwing away most (up to 95-99%) of all possible combinations of parameters. This is possible because in typical strategies varying the parameter value in a narrow range we observe changes in the performance also changed in a narrow range; in other words, noticeable changes in the performance are can be seen not with every combination of parameters, but only with 1/10th to 1/50th (depending on the strategy logic) of all combinations. Therefore excluding the rest we dramatically reduce the computing time.

Genetic optimisation may look as a silver bullet at first glance, however it should be used with great care. Let’s see why.

Unlike exhaustive optimisation where all combinations of parameters are considered, in genetic optimisation we should select those which look best at each iteration, and therefore we need to decide what this “best” means. In other words, we should tell the optimisation engine according to which criterion it should retain or reject certain combinations of parameters. Such a criterion is know as target function. Target functions can be as simple as just net profit, or profit factor, and as complex as Sharpe ratio and other relative performance estimates. The most important thing we should always remember about genetic optimisation is that an incorrect choice of the target function may yield totally different results, sometimes throwing away the really best combinations of parameters and retaining only those which deliver quite a mediocre performance.

Generally speaking, genetic optimization, as well as any other research technique, may be a helpful tool for a trading strategies developer, but no more than that. It is incorrect to believe that this tool alone may replace understanding of markets and price behavior which should lie in the foundation of any robust trading strategy. In next article we’re going to see an example of how it is possible to use just common sense to make an educated guess about strategy parameter values, and how they happen to deliver better returns than the “best” values found in an optimization.

MultiCharts has a decent backtesting and optimisation engine which supports genetic optimisation, and this makes it a really outstanding platform for research and development. If used properly, it can help solving really complex problems, even when designing large portfolios of strategies in various markets. We successfully used it to create a number of robust strategies, and to develop an institutional currency trading platform. That’s why I also focus on genetic optimisation and especially on using it in MultiCharts in my educational programs in systematic and algo trading.

Finally I’d like to note once again that even using really decent tools without understanding how they work and especially what you want to get in the end won’t help you to get consistently profitable. Only understanding of the market and adapting to its ever changing reality allows to thrive.

— Alex Krishtop, founder of Edgesense

Leave a Reply