Thursday, March 19, 2009

Automated Trading Championships – Rules for Efficiency

The Automated Trading Championships (ATC) organised by MetaQuotes is attracting more and more participants each year. Some rules of the competition may seem peculiar at first glance but they are there for good reasons.

Servers efficiency is important to handle the increasing number of EA submissions. As CPU resources are precious and limited, Expert Advisors (EA) need to be efficient in the utilisation of these resources including disk space. For a start, errors are not tolerated because they will increase the server load and errors will repeatedly waste important CPU resources and disk space. Many of these errors are often overlooked because we are not affected by them in trading, live or demo – at least we thought.

Once the competition starts, you have no control over your EA and if it does not behave, your EA will be disqualified. One example is the issuing of orders when your account does not have enough money. In real life, we would have just unplug the EA and not let it deplete our account. In the competition, you have no control and you need to handle such situations in your coding. Let’s run through some of the errors.

1. Not enough money

Use AccountFreeMaginCheck with the lot size you intend to check against your Free Margin before sending out your orders. If there is not enough money, reduce the lot size. Of course, if your account has blown and the smallest lot volume is not even possible to issue, then keep looping your EA until the competition is over.

2. Handling Requotes

Do a RefreshRates and check if your order succeed and repeat this until your order is sent successfully. RefreshRates gets you new price quotes to work on.

3. EA takes too long to run

After you have submitted your EA, the organiser will run your EA from the start of the current year to the date of testing. And your EA should take less than 10 seconds to complete. If not, your codes are not efficient. One CPU resource sucker is the multiple ifs statement. So instead of using

if (A>B && B<C && C==D)

change it to

if(A>B) if(B<C) if(C==D)

I am sure there are many other errors and taking the effort to remove these errors will improve your EA efficiency. Perhaps these little steps will get your EA to do the right thing at the right time when used in real trading.

No comments:

Post a Comment