| / | Articles |
Articles
Trading Systems
Expert Advisors Based on Popular Trading Systems and Alchemy of Trading Robot Optimization (Cont.)
To post a new article, please log in or register
|
Expert Advisors Based on Popular Trading Systems and Alchemy of Trading Robot Optimization (Cont.) [ ru ]IntroductionThus, MetaQuotes Software Corp. opened registration for participating in the Automated Trading Championship 2008 on the 1st of July 2008! It would be a bit inconsequential of me to miss such an opportunity and not to continue the series of my articles with the representation of the logic of building an EA that would formally meet all Rules of the Automated Trading Championship 2008 and that wouldn't admit any critical error during the contest, for which it could be disqualified! It is quite natural that for realization of this event I am using the simplest algorithms of opening positions, the trade factors of which will not be really interesting to us in the context of this article, while the most elementary little things may become most important for searching examination, because they can put one's participation in the Championship forward to several years later! General Idea of Writing an EAIn my opinion, it would be most demonstrative, in our case, to sketch such an Expert Advisor with a detailed description of its construction that actually provides its correct behavior in its interaction with the trade server. The Rules of the Championship determine the amount of open positions and pending orders placed simultaneously to be equal to three. So it would be reasonable to use three strategies in one EA, one strategy per position. We will use the same algorithms with different parameters for opening long and short positions, while making these algorithms open only one position at a time requires from us assigning them the same magic numbers. Thus, we will have six algorithms to enter the market and only three magic numbers! As an entering algorithm, I use a trading system based on change the moving average direction from my very first article in this series. To make the algorithm differ from each other, I use different moving averages in them! Expert Advisor CodeBelow is a version of the EA code: //+==================================================================+ Those who want to have an EA without the limitations stated by the Championship can go in for Exp_16.mq4. In fact, we can see the diversification of trading strategies among three algorithms differing from each other in a certain way. Generally, we have three absolutely independent automated trading strategies in one Expert Advisor. When writing the code, I modified the names of variables in each ATS to avoid coincidences. To make trades, I used functions similar to those in file Lite_EXPERT1.mqh, which are represented by file Lite_EXPERT_Champ.mqh. These functions required minimal changes and corrections in their codes to meet the requirements of the Championship. Alone using the code of such functions in the codes of other Participants' EAs is quite legal, since they are just executive elements of the EA, which have no relation to its intellectual filling that actually controls these elements! So there is no special need to get into all details of these functions or creating something similar and still your own. It would be quite sufficient to read my previous articles in this series to be able to use them. Generally speaking, the use of such functions in writing EAs is as effective as the use of chips in developing and manufacturing electronic devices.
2. The minimal distance from the order open price, at which functions OpenBuyOrder_Ch(), OpenSellOrder_Ch(), OpenBuyLimitOrder_Ch(), OpenBuyStopOrder_Ch(), OpenSellLimitOrder_Ch() and OpenSellStopOrder_Ch() place TakeProfit, is always larger than that defined by the Championship Rules as a scalping one. The minimal distance fo StopLoss is determined by the properties of the traded symbol and is requested from the server. This also relates to pending orders. However, you should consider the fact that pending orders are sometimes processed at prices that turn out to be worse than the requested ones. Your TakeProfits may get into the 'range' of a scalping strategy, in this case! So it would be better to stay away from scalping strategies. Otherwise, at a fair number of gaps (which is quite possible at the end of year), you can find out that your EA has directly come under the definition of a scalping strategy! 3. The smallest and the largest size of a position to be opened, as well as the minimal step of changes, determined by the Championship Rules are written in all these functions with the values of the variables to be initialized. So such errors have already been avoided! 4. Prior to opening a position, functions OpenBuyOrder_Ch() and OpenSellOrder_Ch() check the size of this position and check the position itself for the presence of enough money on the deposit for such a size, and reduce the amount of lots to acceptable values. So, when working with this functions, your EA is safe from errors like "invalid trade volume", in any case. Unfortunately, it is impossible to correct the lot size in pending orders in this manner, since it is impossible to forecast the amount of free assets on the deposit as of the moment the pending order triggers. So an EA writer must be very attentive when initializing external variables 'Money_Management' of functions OpenBuyLimitOrder_Ch(), OpenBuyStopOrder_Ch(), OpenSellLimitOrder_Ch() and OpenSellStopOrder_Ch(), especially for the large values of StopLosses. 5. All functions for positions management hold correct pauses between trades according to the codes of errors occurring. 6. Prior to closing a position or deleting a pending order, or moving the StopLosses, functions CloseOrder_Ch(), CloseOrder_Ch() and Make_TreilingStop_Ch() check the position for being freezed and, if it is freezed, they don't take any actions. 7. Prior to closing a position, function CloseOrder_Ch() checks its net surplus for not being scalping-like. If the position turns out to be within the scalping range, it does not take any actions. 8. Function Make_TreilingStop_Ch() does not move the StopLoss into the price range within which the profit of the position closed by this StopLoss may get into the 'scalping range'. ConclusionWell, there is all there is to what I wanted to tell about the exemplary behavior of an EA on the Automated Trading Championship. Of course, there is one more, rather actual problem that relates to the EA's luxury consumption of CPU resources. However, in most cases, this problem often depends on ineffectively written indicators the EA calls during its operations. And this is an absolutely different pair of shoes. Translated from Russian by MetaQuotes Software Corp. 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.
Hi Nikolay Kositsin, I've got this error during compile... Function "DeleteOrder1" is not referenced and will be removed from exp-file Can you pls include installation instructions??? Thx...
2010.02.22 12:53 nova5000
maria wrote:
Dear all! Now you can have all attached files with English comments on them. Sorry for this delay.
Thanks, Payne
2010.01.13 01:21 payne
Dear all! Now you can have all attached files with English comments on them. Sorry for this delay.
2008.12.16 10:41 maria
<a href=http://www.powerleveling2000.com/WowGold.aspx>buy cheap wow goldBuy Cheaper WOW gold</a>, [url=http://www.powerleveling2000.com/PowerLeveling.aspx]wow powerlevelingwow power leveling [/url] at
2008.11.03 09:28 cicadess
BillW wrote: Is it possible to get source versions commented in english? Or should I just copy and paste from the article? Of course, not! Sorry for this inconsistency. We will translate the attached codes ASAP.
2008.10.21 10:22 maria
Is it possible to get source versions commented in english? Or should I just copy and paste from the article?
2008.10.17 20:07 BillW
yeah, u have made a very good work on the EA, why dont u finish the job by explainig how to use it... We all be very appreciate it... In detail please :)
2008.09.17 18:55 MDR
eatest wrote:
Read articles in the section TesterRosh wrote:
Did you read first article? 'Expert Advisors Based on Popular Trading Systems and Alchemy of Trading Robot Optimization' I have read it but still don't see the instruction how to apply it. Could you show me direct ? Thank you,
2008.09.03 13:46 Rosh
Rosh wrote:
Did you read first article? 'Expert Advisors Based on Popular Trading Systems and Alchemy of Trading Robot Optimization' I have read it but still don't see the instruction how to apply it. Could you show me direct ? Thank you,
2008.09.03 09:48 eatest
Did you read first article? 'Expert Advisors Based on Popular Trading Systems and Alchemy of Trading Robot Optimization'
2008.09.02 18:31 Rosh
11 comments: 1 2
|