“What parameters should I use?”
What values do we use for the order lifetime limits? Or for the profit thresholds? We could meticulously analyse historic data and try to calculate gradients, least-squares fits, Fourier spectra, etc… but the results are only as good as the model and our model is less mathematically rigorous than a drunken poker match. Instead, we can let an artificial intelligence loose on the historic data, and have it estimate the ideal parameters for our rules.
The Terminator
Artificial intelligence is a large subject in itself, and there are many models (primarily within the subfield of Machine Learning*) that could be applied to our optimisation problem – gradient descent, neural networks, and evolutionary algorithms are all popular options for this kind of problem. The MetaTrader 4 trading platform uses a subtype of the latter category, a genetic algorithm, to optimise parameters for EAs.
* for more information, see my incomplete and probably erroneous notes based on a Coursera course, available here.
Hasta la vista, baby
We let the AI train our EA on the historic data, and several minutes later it returns with a list of parameter vectors that produced obscenely high profits. Too good to be true? Not at all – if you sent the EA back in time and started running it at that exact moment and it had no significant effect on the evolution of the market during its execution time then in all likelihood you would become obscenely rich. Start it an hour too late or early though and you’ll probably be bankrupt within the hour.
Variance and cross-validation
To anyone familiar with machine learning, this is due to overfitting or variance. The AI has learnt the random, noisy fluctuations in the data in addition to the general behaviour – and expects the same noise in new data fed to it. To prevent this, we test the outcome from our AI against new datasets that weren’t used during training – the cross-validation datasets. If the EA ha similar performance in the cross-validation as it did with the training data then our EA is probably well-trained or horribly biased. Either way, it is still very unlikely that it will be profitable to use this EA. Bias (or underfitting) occurs when the AI hasn’t learnt enough from the training data or when the training data is not a close enough representation of the problem. Consequently, the results of the AI are biased based on what little information (if any) it has learnt or by the actual design of the AI itself.
Bias will result in an EA that generally makes losses in any situation whilst variance will result in an EA that can “make” extremely high returns on the historic training data, but fails rapidly when run on slightly different historic datasets or on live data (or on pretty much any dataset besides the training data). It’s a chaotic solver for an ill-posed problem, so imagine butterflies and hurricanes, but where the butterflies are zombies and the hurricanes spray Plutonium.
The resulting performance
As Nostradamus predicted, EAs based on the preceding rules will make you homeless at record speed. You can slightly delay this by optimising your EA properly though 😉