| / | Articles |
Articles
Tester
Genetic Algorithms vs. Simple Search in the MetaTrader 4 Optimizer
To post a new article, please log in or register
|
Genetic Algorithms vs. Simple Search in the MetaTrader 4 Optimizer [ ru | cn ]
1. What Are Genetic Algorithms?The MetaTrader 4 platform now offers genetic algorithms of optimization the Expert Advisors' inputs. They reduce optimization time significantly without any significant invalidation of testing. Their operation principle is described in article named Genetic Algorithms: Mathematics in details. This article is devoted to EAs' inputs optimization using genetic algorithms compared to the results obtained using direct, complete search of parameter values. 2. The Expert AdvisorFor my experiments, I slightly completed the EA named CrossMACD that you may have known from the article named Orders Management - It's Simple:
Now it is a practically completed Expert Advisor. It will be convenient to optimize it and use in trading. You can download EA CrossMACD_DeLuxe.mq4 to your PC and test it independently. 3. OptimizationNow we can start to optimize the EA. Three tests will be conducted with different amounts of optimizing searches. This will help to compare profits obtained using genetic algorithms in various situations. After each test, I will manually remove the tester cache for the subsequent tests not to use combinations already found. This is necessary
only for the experiment to be more precise - normally, automated chaching of results
just enhances the repeated optimization. To compare the results, optimization using genetic algorithms will be made twice: first time - in order to find the maximal profit (Profit), second time – to find the highest profit factor (Profit Factor). After that, the best three results for both optimization methods will be given in the summary report table sorted by the given columns. Optimization is purely experimental. This article is not aimed at finding inputs
that would really make greatest profits. Test 1
It must be noted that, when using genetic algorithms, the expected time of optimization is approximately the same as that of optimization using direct
inputs search. The difference is that a genetic algorithm continuously screens
out certainly unsuccessful combinations and, in this way, reduces the amount of
necessary tests several times (perhaps several tens, hundreds, thousands of times).
This is why you should not be geared to the expected optimization time when using
genetic algorithms. The real optimization time will always be shorter: ![]() Direct search ![]() Genetic algorithm As you see, optimization using genetic algorithms took less than four minutes instead of the expected five and a half hours. Optimization graph with genetic algorithms also differs from that with direct search. Since bad combinations have already been screened out, the subsequent tests are conducted with combinations of inputs that are more profitable by default. This is why the balance graph goes up: ![]()
Results Table:
As you can see from the table, optimization using genetic algorithms is some tens of times faster! The results are practically the same. There are several results with maximal profit of 4.72, this is why different combinations of inputs are reported, but it is not very important. Now let's try to decrease the amount of searches, but increase the testing time. We will use the "All ticks" model for this. Test 2
Results table:
For such an amount of searches, the optimization rate differs 25 times which is not bad either. The results conincide by practically 100%, the only difference is in the StopLoss value on the third pass. The profit factor remains maximal. Now let's try to increase the amount of searches and descrease the testing time.
Let us use the "Control points" model for this. Test 3
Results table:
The situation has changed. The optimization periods coincide (an insignificant error is admissible), and the results are identical. This can be explained through that optimization consisted of only 1331 searches and this amount of passes is just not enough for using genetic algorithms. they have no time to "pick up speed" - the optimization is faster due to screening out certainly losing inputs combinations, but having such amount of combinations as above, genetic algorithms cannot define what "parents" (inputs combinations) generate bad "off-spring". So, there is no sense to use them. 4. ConclusionsGenetic algorithms are a nice addition to the МТ 4 strategies optimizer. Optimization is dramatically enhanced if the amount of searches is large, the results coincide with those obtained by regular optimization. Now there is no sense to use the full search in inputs. Genetic algorithms will find the best result faster and no less effectively. 5. AfterwordAfter having written the article, I satisfied my curiosity and launched optimization of CrossMACD_DeLuxeon all inputs. The amount of combinations made over one hundred million(103 306 896). The optimization using genetic algorithms took only 17 hours, while optimization using search in all inputs would take approximately 35 years(301 223 hours). Conclusions are up to you. Translated from Russian by MetaQuotes Software Corp.
Original article: http://articles.mql4.com/ru/135
Warning:
All rights to these materials are reserved by MetaQuotes Software Corp.
Copying or reprinting of these materials in whole or in part is prohibited.
Thanks for the great explanation and thorough testing Andrey! Very helpful.
Nick, there is a checkbox in the Strategy Tester when you click "Expert properties" -- it is on the first tab "Testing"
2007.09.27 18:29 dusktrader
I have been looking for ways to optimize optimization, and this article intrigues me. How exactly would I go about enabling "genetic optimization?" Thanks Nick
2007.09.09 00:25 Kremnari
2 comments
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||