Monday, May 4, 2009

No more hedging orders NFA – the rule243 turmoil for EAs

What are the implications of a First-In First-Out (FIFO) for offsetting transactions for Rule 2-43b. Apparently it is just not about doing a long and then when you “hedged” and do a short on the same currency pair, your long will be offset first. If you issue another long order followed by a previous long order, your first order needs to be processed first. In order words, if you have a first long order with no takeprofit set, and then you issue another long order with a takeprofit, the second cannot be processed because FIFO means the first long order has to be closed!

How many strategies will be affected! A simple CloseAllOrders script now has to look for the very first entry and close it first, followed by the next earliest order. You can’t close randomly now. In fact you can’t even close orders that are later than the first!

What about pending orders, ie stops and limits? Which ever way you go, you still need to process the first order first.

This rule is going to cause the US brokers confusion and the traders using them. It’s worst for EAs traders. Because of its automated nature, you might wipe out your own account executing in this new rule environment. Although the date of 15 May 2009 has been set, brokers who has no non-US operations will now have to think of new solutions, and we have not heard from any yet.

What shall we do in this turmoil? If your EA executes more than one order per currency pair at any instance of time, be they market or pending orders, don’t use them for now. Switch to one that issues one order per currency pair at any one time.

If your broker suggest you transfer out to a non-US operation, go for it. The hassle to understand how your US-based broker is going to implement this rule will stall your EA operation for a while.

If you are stuck with the current US-broker and you don’t have any EA strategy that don’t use “hedging” in their definition, you can either take a break, do manual trading or switch broker. Whatever it is, don’t execute your EA or worst still, leave them unattended thinking that things are going to remain the same.

For example, IBFX will be switching to this rule on 8 May 2009, earlier than the 15 May 2009. They said to use their demo servers to check out what the new rule means. Excuse me, nothing has changed and they still allowed hedging on the same currency pairs. Yet they are going to switch over to the new rule soon. And their reply on pending orders drew a “We don’t know the answer”. So you still want to leave your EA running next week?

Thursday, April 30, 2009

No more hedging orders NFA – Changing the forex strategy landscape

Everyone is talking about it! No more hedging on the same currency pair if you are using US-based brokers. The National Futures Association will be enforcing a Rule 2-43b that prevents a long and short being taken on the same currency pair at the same time with effect from 15 May 2009.

The reason given is that it is disadvantageous for a trader to be using such a strategy which incur costs (spread from long and spread from short) and these strategies are detrimental to trading. So for the sake of traders, brokers are not allowed to have hedging of the same currency pair.

So if you have a long order, and then issue a short order, your long will be closed, leaving your short order in place. You cannot have opposing trade orders in the same account for the same currency pairs.

If you must do it, open a different account, with one account doing long trades and another account doing short trades!

Implications for EAs are great. They have to be re-written. If the strategy has no changes, you need to split the strategy into two to be handled by two different accounts. How troublesome.

What about pending orders that are opposing? What if you have ensured that the orders are not triggered at the same time or ensuring that one is a market order and the other is always a pending opposing order. I posed that question to IBFX and their reply was “they don’t know the answer yet”.

Yes, it is going to be tricky if they don’t even allow opposing orders that consist of pending orders. A lot of other strategies has to be re-written. For example a Stop and Reverse strategy must really have the losing order “stopped” first before triggering a “reverse” order. And one must be careful to code in the spreads as well. A lot of precision and thinking now. No more sloppy strategy coding.

Thursday, April 23, 2009

Automated Trading Championship - My 2008 Experiences

The reason why I can write so much on MetaQuotes' s Automated Trading Championship is because I was a participant in 2008. Everything was new for me, and the mad rush to understand the rules and then coding an expert advisor, discovering the intolerances of all sorts of errors, and finally dishing out a half-baked EA that got stuck in the early part of the competition.

I coded an EA based on a weekly strategy, and risked on the higher side for the lot volume so that the EA can get ahead. The currency pair traded was EURUSD. I have always wanted to do a multi-currency pairs EA but just could not find the time for it.

One week after the competition started, EURUSD threw up a more than 100 pips gap over the weeks, and my EA was "lost" simply because I did not handle the big gap.



But on the whole it traded very little but managed to get a profit of $1451, ranked at 95 out of 705. Nothing to be proud of especially over such a small gain. But then, it did give a nice feeling that I managed to be the few who could maintain the equity and gained some profit.







More importantly, it made at least 5 trades which was a competition requirement. But I guess it does not matter because the true performance of the EA has been marred by its inactivity for many weeks, and so it is not reflective of its capability or incapability.

Wednesday, April 8, 2009

Automated Trading Championship – Why Join?

What are the possible reasons for wanting to participate in ATC? The reasons are many, from the most trivial of just having some fun to potentially finding business opportunities. Let’s discuss some of this.


1. Self-selected MQL4 Olympian


Well, when you are a participant, you country is listed and so are your fellow countrymen. Within that you can have fun to see if you are doing better than them or better still in a small world like us, it looks like an Olympic game. Just think - you cab select yourself to represent your country.


2. Self-disciplined EA


Your EA needs to be efficient in using computing resources and error-free. Even if you have escaped the scrutiny before the competition, you may run into some errors which will disqualify you. Participating will help you build more efficient EAs and force you to discipline your EA and yourself and up the ante.


3. Making new MQL4 friends


Hey you can go around as a participant and drop messages on other participants and they on yours, so hopefully you get to know more like-minded MQL4 freaks.


4. Benchmark your EA


This is a good time with all participants on common ground to pit your EA against others and see how well it performs. It will tell you how good or bad your strategies are. Or maybe it is not the strategies but poor coding. Whatever it is, it will help you to see what kind of EA you have written.


5. Selling your EA.


If your EA show promising results, rest assured that there are many eyes from all over the world who will express interests to purchase your EA.


6. Business opportunities


Or you might get requests by intermediaries who will host your EA as a list of offerings to their customers and earn some bucks in return.


I am sure there are more. If you can think of any, drop me some comments!

Thursday, March 26, 2009

Automated Trading Championship – Rules that are hard to understand

It is important to understand all the rules of MetaQuotes’s annual Automated Trading Championship. Last year’s rules are found here.

One of the most difficult rule to understand is under Trading Terms #4.

“The minimum trade size is 0.1 lot, the maximum one is 5 lots with the step of 0.1 lot for each order.”

Here is a breakdown of what it means:

1. There is only one decimal place for lot size ie 0.2, 1.3, 2.4, etc. You cannot place lots with 2 decimal places ie 0.12, 1.32, etc

2. The smallest lot size allowable is 0.1.

3. The largest lot size is 5.0.

4. “step of 0.1 for each order” means you can place a lot with 1 decimal place as in point 1. It does not mean that after you place a lot size of 0.1, the next lot size allowable is 0.2. No, it just means use one decimal place.

I think this is the most difficult rule to understand, the rest seems pretty straightforward. However, there are two more that may disqualify you from participation. Under Participants, rule #5 and #6

#5. The Participant can be registered only once within the Championship. Registration of your friends or relatives instead of you will result in your disqualification. If any registered persons display their ignorance of trading, they will be disqualified.

#6. The attempts of multiple registrations or use of anonymous proxies will result in unambiguous disqualification of the Participant.

These two rules are to prevent multiple entries by a single person, who uses other people’s names for registration. I think the organisers detect this by checking for submission of EA entries from the same computer. There are always dispute over this but to avoid any misunderstandings, it is best to submit from your own computer and let no one else use your computer to submit theirs. After all, if your friend is in automated trading, he or she should have their own computer and connections to be fiddling with EAs! Apart from detecting where the submission source is, I do not know how else this can be checked.

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.

Thursday, March 12, 2009

Automated Trading Championship

The Automated Trading Champion (ATC) is a contest by the maker of metatrader to encourage the use of automated trading through their platform. Started in 2006, the interest in this championship has grown tremendously. In 2006, there were only 258 qualified participants. In 2008, it has grown to 705. The results is even more impressive. Give a starting equity of $10K, the winner in 2006 grew his account to $35K. Then in 2007, the winner had a balance of $130K. But in 2008, the winner won the competition at $169K. The table below summarises what has happened over the past three years.

What is even more interesting is that the number of participants who could grow their accounts to more than the equity given is a vey small percentage. Less than 20%of the participants were able to grow their accounts; the majority were not able to win a cent. There are many reasons, I am sure. It is only a competition using demo accounts and no real money is used. The participation is free and so there is no pain on the side of the participants except developing a trading strategy and coding the ideas into an EA. This environment will drive the behaviour of the trading strategies used by the participants. As the championship grows in numbers and increasing balance obtained, the EAs will only get more aggressive and risky. Most participants will risk all their capital to forge ahead, something that most will not do in real life and with real money.

Perhaps it is time to change the competition's requirement so that more realistic EAs will be written. After all, many people are interested to use the EAs in real accounts and want to buy them from the owners. Nothing wrong with this. The sad aspect is that most of the winners turned losers after the competition. And we are taken for another ride...

  2006 2007 2008
Total Registered Participants 753 2011 2420
Total Qualified Participants 258 603 705
Total above USD10K 44 91 128
Highest Balance (USD) 35,175.56 130,475.45 169,584.64