## Wednesday, December 7, 2016

### Testing and Analysis of Algorithmic Trading Strategies in MATLAB (Part 4) – Genetic Algorithms

This post is about how important is to use different types of optimisation methods such as genetic algorithms and parallelisation to get results faster.

## Genetic Algorithms Optimisation

Despite the fact that the genetic (evolutionary) algorithm principle is very well explained in the MathWorks webinars, in the examples, however, it is used only for optimisation of the choice of a strategy group from a set. This is a good example of the use of these algorithms, however, it happens that there is a need to set many variables with significant intervals for one strategy, you don't get by with one iteration and the parallelisation of processes – calculations can take several days. Certainly, there are strategies in the final stage of optimisation, when we almost surely know the trading strategy is successful, we can wait for several days as well or rent the whole cluster - the result might be worth it. However, if we need to "estimate" the results of a "bulky" strategy and decide if it is worth it to spend the time, then genetic algorithms may be perfectly suitable.

We provide the possibility to use three methods to optimise the strategy in WFAToolbox:

• Linear method – it is a usual mode of sorting in which you will see all intermediate (suboptimal) results. It gives maximum accuracy.
• Parallel method – all kernels of your CPU will be used. It does not allow to see intermediate results, but significantly speeds up the operation. It gives maximum accuracy during increase of computation speed.
• Genetic method – it uses the evolutionary optimisation algorithm. It allows to see suboptimal values, but gives the result close to the best. It's not a very accurate method, but it's precise enough for the initial "run" of the strategy. Very fast.

 Genetic Algorithms

We are often asked if WFAToolbox - Walk-Forward Analysis Toolbox for MATLAB has the ability to use the GPU in calculations. Unfortunately, GPU is not suitable for all tasks and its use is very specific. In order to use it, you need to adjust the logic and the code of each strategy for graphic cores testing. Unfortunately, due to such non-universality of the method one cannot use GPU in WFAToolbox.

## Monday, December 5, 2016

### Testing and Analysis of Algorithmic Trading Strategies in MATLAB (Part 3) – Visualisation of Process

Continuing Part 2 of the discussion of problems and solutions in testing and analysis of algorithmic trading strategy in MATLAB, I invite you to read this post about problem of unavailability of visualisation of the processes in modern software solutions for testing trading systems.

## Visualisation of Testing Process

In my work experience, I often analysed other popular platforms for trading strategy testing, such as TradeStation, MetaStock, Multicharts etc. and I was always surprised at how little attention was paid to visualisation of the testing process. The thing is that when we don't see the results of the intermediate, sub-optimal values of optimised parameters, we often throw away gold along with the dirt. The matter is because of an overly broad sampling, the strategy adjusts the parameters the way we either see a "perfect strategy" which fails in real life or see one or two deals, which are supposedly the best because it was selected such time interval data where the best trading strategy would be "buy-and-hold", but why are then other strategies necessary for?

 Visualisation of trading strategy testing process in MATLAB (proposed in webinar)

As a result, without seeing intermediate results, we need to «blindly» change the parameters to try to get the better data; or watch it in some 3D or 4D (colour is the 4th dimension), as proposed in webinars. The analysis of values in the N-dimensional spaces can definitely be an alternative, but has several limitations:

• What if there are more than 4 dimensions?
• When you see what signals and at what frequency they appear in the price range, you have almost all the necessary visual representation of your strategy: the frequency of the transactions, their profitability (income curve), the accuracy of opening, the similarity with other suboptimal values, etc.; that cannot be said about the performance in N-dimensional space where all useful information is, in fact, that the optimum value is not only one but there is a whole range of suboptimal values in one or more areas.

While optimising a strategy in WFAToolbox – Walk-Forward Analysis Toolbox for MATLAB®, as a new optimum value is found, the trading strategy signals in the period in-sample and out-of-sample immediately appear on the chart, so you can always control what range of options you should assign, and also you can pause the optimisation without waiting for the end of test, as it becomes clear that something went wrong or everything is fine.