Showing posts with label download. Show all posts
Showing posts with label download. Show all posts
The modification of the EA to make it multi-currency was a tough job and resulted in a heavily modified code of my MT5 expert advisor. Today, I’d like to turn my head to a less complicated yet very important issue — proper position sizing in the ATC EAs.

The Problem

The ATC 2011 rules state:

The minimum trading amount is 0.01 lots, and the maximum is 5 lots, with an increase by 0.01 lot on every order.

The maximum combined amount of positions and pending orders’ lots, regardless of the direction on one symbol, is 15. Stop-losses and take-profits are not taken into account.

This means that it won’t be possible to trade with positions greater than 15 lots. It’s quite bad if one wanted to use an aggressive position sizing strategy and increase orders volume indefinitely. When the EA reaches 15 standard lots limit, the build-up of the balance no longer will be exponential, even for a very profitable strategy. Another issue is that the position bigger than 5 lots need to be opened and closed with more than one order (fortunately, stop-loss and take-profit orders are exempt from this rule). For example, if you wish to open 12 lots long on EUR/USD, you have to send two orders to buy 5 lots each and then one order to buy 2 lots. If you wish to close a position of 12 lots, you have to send two orders to sell 5 lots and then one order to sell 2 lots (of course, you could use 3 equal orders 4 lots each, but that’d be quite an exotic method :) ).

The Solution

There are two basic ways to avoid breaking the above-mentioned rules. The first one is to implement your own Buy/Sell procedures for position opening and closing. The second one is to modify the standard MQL library Trade.mqh, which supplies quite powerful PositionOpen() and PositionClose() functions.

I’ve chosen the second way. A coder from MQL5.com forums had shared his version of the modified Trade class for ATC and I’ve modified it to work properly with my EA. The initial version had some errors (it didn’t prevent big orders from sending when no position for the pair was open). If you are anxious to see this modified library, you can scroll down to the Downloads part of this post. The modified lines are marked with “//////////////////////////////” comment.

Results

Obviously, such trading volume limitation has a potential to reduce the performance of the profitable EA. After all, even if there’s enough free margin in the account to open a bigger position, the expert advisor will have to limit the position size with 15 standard lots. If the profit of the previous version of my candidate EA (multi-currency one) was $247,461.84 during the 6-month (2011-01-01-2011-07-01) backtest, the latest version (the one that implements the position sizing limits) showed only $206,618.68 profit for the same period. Nevertheless, it’s still a nice result for me, though it may be too low to achieve anything significant during the Automated Trading Championship this year.

Downloads

The whole package of files required to run this expert advisor can be downloaded for free. It contains the EA file, the custom indicator it uses and the modified Trade library that follows the rules of ATC 2011 position sizing:

* Test EA + Variable Lots + Z-Score Optimization + Multi-Currency + Position Sizing

You can also download the backtest report of this EA:

* Multi-Currency with Position Sizing Limits — Backtest Results

In the next issue of the RTATC2011 series, we’ll talk about getting the EA to work in the ATC 2011 trading conditions, with all its requotes, delays, slippages, etc.

You can read the first entry in the RTATC2011 journal to get some basic idea of what’s going on here.

P.S.: 2 months and 9 days left for registration in ATC 2011. 994 participants registered so far. Only 6 participants left to 1,000! Yay!