Thursday, December 31, 2009

2009 Summary

2009 is ending. This one year marks the greatest change I have seen in the world of Metatrader platform. Let's reflect on this.

Metatrader Success
MT4 is now one of the most succesful trading platform for retail forex traders. The platform is simple to use, easy to understand and with a host of EAs and indicators from the Internet. You can download the software easily and there are many brokers providing free demo accounts. Reputable brokers who did not implement metatrader had jumped in - Gain, MB Trading, FXCM and Citibank to name some. This is a Russian product and they have got it right!

NFA disruptions
Lots of new rules from US's NFA seems to target metatrader because it has become a platform that is too lax eg no more hedging with the same currency pair. But it is partially this that makes metatrader successful. Brokers have implemented different strategies to counter the change of rules: from moving to a location outside US to developing a middleware layer to mitigate the changes.

No more universal EAs
So with the NFA disruption and different mitigating strategies used, it is no longer possible to implement an EA that can be used on different brokers. One must now know the idiosyncrasies of each broker.

MQL5
MQL4 is based on functional programming. This is considered a yesterday technology. But it is simple and many can learn it quickly, including traders who have no programming background. MQL5 is object-oriented and MetaQuotes has decided to "upgrade" to this newer in the name of execution speed and of course to bring it in line with today's programming technology. Will MQL5 succeed? A lot of EAs and indicators need to be re-written. The platform has been released to the public for beta testing.

No Automated Forex Trading Chanmpionship
The yearly championship run by MetaQuotes did not occur this year. MetaQuotes explained in the early part of 2009 that they are working hard to release MQL5 and will instead have the competition in 2010 but based on MQL5 so that they can promote their new platform. The Russians had a head start in this as the Russian platform had been made available long before the English version. Well, more importantly, will MQL5 enjoy the same success as MQL4 and will MQL4 ever be replaced, even though the championship will now be focussed on using MQL5 and not MQL4?

Saturday, December 12, 2009

Tips for asking someone else to write your EAs or Indicators

I have been coding quite a bit of EAs and indicators for some people who I converse over the Net but have never met or know them personally. Interesting, there are common tips that I like to share so that you can make the transformation of a strategy to an EA or indicator easier.

STARTUP PHASE

1. Write down all the steps. Yes, if you can't pen down your strategy, it will never be clear to anyone except yourself. You might even discover that you are not clear about it yourself. Of course, if it is a "commercial" strategy, your job is all done up, except for some clarifications. And, yes include charts with clear annotation.

2. Write down your steps in English and unless you know MQL4 coding a fair bit, do not mix the English description with the code. For example, if you want a trade entry at a start of a new day, then say so. Don't mix in a code that say start trade at Hour[0]=0 unless you really mean the 0 hour.

3. Be prepared for lengthy clarifications. Coding needs precision and if the coder is uncertain, he will check back with you. For example, is the start of a new day, the broker's server "new day" or is it some time zone reference that you need?

4. Language is still a problem. We are all in the forex world, but still we can mean differently although we are using the same words. For example, MT4 has stops and limits and a buystop means placing an order above the current Ask price at some acceptable distance and a buylimit means placing an order below the current Ask price at some acceptable distance. But when someone said there will be a limit order or stop order, he could mean:
  • "a limit order is used to start a trade if the price hits a fixed level"
  • "a stop order is used to close a trade if the price hits a fixed level "

Or another person may say

  • "STOP is to do with LOSSES and LIMIT is to do with PROFITS"; with a stop order you decide how much you are prepared to lose ie stoploss; with a limit order you can enter a trade at a specified level and you can specify when to exit (takeprofit)


So why is there so much confusion. Well it is because MT4 allows one entry order with stoploss and takeprofit taken simultaneously. For brokers with ECN, you can only place an entry with no stoploss and takeprofit. You can do your takeprofit and stoploss at the next step. As a result buystop or buylimit is really peculiar to MT4 and hence no commonly understood across the forex market. Of course, the orders under MT4 platform are a lot easier to understand and hence one of the reason for its popularity.


5. Where are you trading from? Sometimes it matters where and when you are trading from, so specify your city and country and the local time you are trading from.


TESTING PHASE

6. With your strategy coded, it is time to test out the EA/indicator. If there are errors, go to the expert and journal tabs and copied out the error messages. It is easier to debug with these messages.


7. For clarity, always specify which broker you are using and better still note the following:

  • use of fractional pips ie 2/4 digit or 3/5 digit; note whether this is also true for the live server - sometimes the demo server is on 3/5 digit system and the live system is on 2/4 digit system
  • note the server time in GMT
  • does your broker use suffix like EURUSDm instead of EURUSD?
  • is it an ECN broker?


EVALUATION PHASE

8. You will be surprised that most of the time, your EA will not do well. There are many reasons for this. Be prepared to discuss the strategy with your coder, who is preferably a trader himself otherwise there will be little value-add.


9. Hidden intuition. A lot of traders use intuition based on experience and it is a challenge to capture this hidden intuition. This is the secret to a successful EA. Think hard what you are looking for that is not documented in the steps. Sometimes the answers may not be even found on the screen.


10. Please do extensive testing before going live.


Hope you have found this useful and hope you can translate the gems in your head into a program that can make trading easier for you. Make that a goal for 2010!



Wednesday, November 18, 2009

Me at SGBarcamp4

I have put my thoughts together to finalise the talk, "Automated forex trading and the world of MQL4", for the coming Barcamp at Suntec Tower 3, Singapore this Saturday. The people who attend such barcamps are broadly two groups: the the techies and the social media/networking enthusiasts. So we have people who are hard core coders and those who are knowledgeable about Web2.0 stuff.

I hope to cover the "101" of automated forex trading using MQL4; that's alot for a half hour session that is not supposed to be one-way but interactive. On the other hand, I hope to introduce interdisciplinary mashups of talents into the world of forex trading - so i will cover the 1st to 5th derivative of linear displacement, price distribution with skewness and kurtosis and astro finance. I don't have time to put together the frequency domain trading via cycles and bandpass filters. Not sure if I have time to cover so much, we will see. Let's see if we can surface more talents into this difficult field, otherwise it is good to let programmers know that perhaps this is one area and minefield to explore, with caution.

Sunday, November 1, 2009

What you plan is not what you get

I have an EA that runs well on demo account but fails miserably when used on a live account. Why?

I am sure you have encountered this and the first thing you probably did is to say the strategy fails, then drop the EA and look for the next holy grail.

The truth is - there are many differences using a live account as opposed to a demo account. Let's explore a few of them:

1. Complex-previous-trades-dependent strategies - this is a curse of automation; with the ability to execute complex trading strategies because of automation, strategies that hinge on a previous or many previous trades are doomed to fail. Why? When the sequence is broken, you will not be able to recover, even though you may have put in alot of mitgating actions to counter this break.

2. Someone at the other end will figure out your strategy and plan for your failure. You can't trust anyone, no, not even your broker. Do a google and find many horror stories. Someone will claim to have been cheated by broker A. Another may say that for all the years with Broker A, he has no problem.

3. Have you encounter many error conditions like lost connection, trade with wrong prices, etc? How genuine are these error conditions? If your EA does not forsee this, and if you do not incorporate the "right" mitigation strategies, your account can be wiped out either slowly or quickly, but surely.

4. You won't believe the things that can happen. For example. you execute a trade. Your EA thought the trade was executed (even though you have put in extra checks) and the other side happily drop your request and not even informed your EA - in the name of an error condition.

5. Really the truth may be that your EA was not written properly and not doing what you wanted it to do.

Just be aware that real trading account is different from a demo account. There will be some winners, and some losers. You need to lose so that someone else will gain. Tread carefully...

Monday, October 12, 2009

Me at SG Barcamp

My friends are organising a barcamp in Singapore on 21 Nov 2009. I have decided to join in the fun and hope to present the MQL4 automated forex trading to a group of fellow developers in other areas.

What is a barcamp? Essentially a conference where the contents are user-generated. It is usually open, participatory and contents used to be technical but nowadays there are more fun topics like "How to date a Japanese girl" (presented by a Japanese girl). Attendance can range from a few hundreds to a thousand. Barcamps are getting popular with a group of like-minded people hustling together to explore the changing world advanced through new IT technologies and ideas.

One has to fight for a slot so hopefully I can share something. Otherwise, there will always be a next.

Sunday, October 11, 2009

MQL5 ready for puiblic testing

It is going to be a busy period down the road now, with MQL5 being ready for public beta testing tomorrow (12 Oct 2009). MQL4 has become so popular that a lot of big time brokers have joined in. I am not sure if MQL5 will enjoy the same success.

First, MQL5 is object-oriented, so it will be a steeper learning curve. Most retail forex traders will find it harder to learn.

Second, the compatibilty with MQL4 is not maintained because the creators said the language concepts are just too different. They tried to keep the compatibility but they couldn't. So all EAs and indicators in MQL4 have to be rewritten in MQL5. We can only hope for someone to write a tool to do a conversion for us.

Third, there are just too much success in MQL4 to motivate people to migrate. The best thing happened so far is NFA's new rules which have rendered MQL4 useless so much so that some US brokers just gave up, or encourage traders to use the non-US operations.

We shall see. For me, it just means spending some time to study MQL5 and prepare for the day when brokers indeed stop using the MQL4 platform and force us to move on to MQL5.

Wednesday, October 7, 2009

More Japanese indicators

Japanese are very innovative people, and you can see this from the progress of the nation. Step into Tokyo and you will discover that they are so willing to use IT and electronics in their everyday processes. It is not a "should I" but instead you will find IT/electronics quite embedded. Take for example the $10 haircut idea copied from Japan which is commonplace in Sinagpore now. Using a machine to collect the $10 notes in exchange for a token card before having your haircut solves the money collection issue by the bosses. No fraud, no miscounting and best of all the money is safe in a machine and no robber can come to clear the till.

OK, I digress. I just wanted to express my admiration of the Japanese and share their innovativeness even in trading. I talked about the Ichimoku cloud chart just a while back. Take a look at other Japanese invented indicators like Kagi charts, or Renko charts. Yet another way of looking at the prices without having to worry about the time factor. Renko candles are just bricks and boxes with no regard to time - just price action reactions. Apparently you can spot more trading opportunities using Renko than candlesticks, afterall the inclusion of open times, closing times, high and low are arbitrary formulated based on time frames. Change the time frame, and information from candlesticks change. Oh by the way, the often used candlesticks is also a Japanese invention.

Kagi charts are similar to Renko charts, paying no regard to time. Kagi charts are joining lines that look like steps depiciting highs and lows and changing of higher highs and lower lows.

Not that these indicators are important to me. I use EAs and hence don't even look at charts. So if we can have charts with no time factor, there must something to all these that is worth investigating more,

Tuesday, October 6, 2009

Clouds watching

Since I am now in Tokyo, Japan, basking in the beauty of the Land of the Rising Sun, it is only appropriate to write about a Japanese indicator called the Ichimoku Kinko Hyo developed in 1969.

When I first came across this indicator, I was not only fascinated to find out what the name means, but the colourful lines and meshes that seem to make this indicator mysterious.So what does Ichimoku Kinko Hyo means? Translated literally it means "one-glance balanced bars/chart" or non-literally, "chart equilibrium at a glance". It comprises of moving averages over a determined period and shifted moving averages. In short, it is really a trend indicator with support and resistance lines. Ichimoku Kinko Hyo or Ichimoku in short (or some like to it cloud charts) is commonly recommended for longer time frame trading such as daily or weekly. But some have shared success even at lower time frames. But I still think that one should stick a minimum of daily time frame.

It used to be difficult to find information about this indicator, but do a google now and you will find tons of them including books. So I shan't write much about this.

Monday, September 28, 2009

Operating in a different domain

It has been a while since I last blogged. I have been investigating a few interesting ideas. One of them is digital filters. Filters are what it says it is – filter off unwanted signals. In the world of digital filters, we are operating on the frequency domain and not time domain. They are related – after all, time is the inverse of frequency.

So what is the advantage of operating in the frequency domain? One clear advantage is the reduction in lag time. A low pass filter lets low frequency components pass through but filter off high frequency components. One way to achieve this is to use a moving average algorithm. Therefore most low pass filters are smoothers and hence the spiky signals get attenuated and a smooth curve can be obtained. Unfortunately this introduced lag, and most indicators are laggards. The more we filter off, the more lag it introduces.

A high pass filter filters off low frequency components, the exact opposite of the low pass filter. Add the high pass filter to the low pass filter and wala, you have a bandpass filter. A bandpass filter determines the range of frequencies you want to let through.

Sounds like a bunch of electronics engineering. Yes, it is and google "John F. Ehlers" and discover a world of trading equivalent indicators that are derived from electronics engineering.

And here is a demonstration of the power of digital filters.

Thursday, July 30, 2009

EAs are not universal anymore

It used to be when you write a metatrader EA, it can be used across all brokers who has this platform, and the only thing to take care of is the server time as each broker has different GMT settings and that is provided the trading strategy is time dependent.

Today it is fragmented, in just a matter of months. The first is fractional pips, some brokers have switched to offer this, others remain. But this is easily solved. Next are those US brokers who are NFA registered. In this category, there are different implementations. One broker said everything remain the same, just make sure your lot sizes are not the same so that some backend system will handle the no stoploss, no takeprofit, no trailing stops that NFA has forbidden. Of course all NFA brokers cannot offer hedging now. Then on the other side where brokers are not US based, there are those who offer direct ECN connectivity. That means, you cannot send orders with TP and SL. These two parameters must be zero. But at the next tick, you can send in a modify order command.

Gone are the days where we can have more universal settings and code. So even with one platform, there are so many permutations of implementation that is getting tedious to write a universal EA.

Thursday, July 16, 2009

Book Review - Mechanical Trading Systems

I came across this book that is worth mentioning only because there are not many books covering automated trading systems. The book is "Mechanical Trading Systems" by Richard L. Weissman, John Wiley & Sons, 2005.


It is a book about mechanical trading system, that is, systems that can be automated or expert advisers (EAs), a term I have been using frequently. It is interesting because it explores the psychology of different trading systems that a trader needs to know in order to match the system to his own trading psychology, something I had talked about in here. But there is no holy grail, it appears the author has some successful automted trading systems which he openly said he will not reveal. His purpose is to share the usefulness of automated trading and how it can be applied as follows:


1. Trend-Following Systems: patience is the key and not getting out of a profitable trade too quickly. The psychological make-up to trade such systems are patience to wait for trade entries, long drawn trades (could be months), ability to give back a large portion of profits.


2. Mean-Reversion Systems: these systems are intermediate term trades and needs discipline; discipline to overcome crowd psychology, media hype and action price reading. There will be more losing trades than winning trades, but the losing trades are small in value but consecutively large.


3. Short-Term Systems: there could be many trades in a day and require quick thinking and fixed formulas for entry, exit and money management. These type of trading is intensive and require the trader to stay seated to the screen (but this is where automated trading comes in handy).


Most of the examples of trading systems are based on technical indicators. I can only infer these are probably not the systems to use since they have been revealed!


The author has also covered the usefulness of automated systems for backtesting, forward testing and optimisation of trade parameters. At risk is the convenience of optimisation and curve fitting of a set of data that does not represent future prices.

So this is a book worth reading so that you know yourself better and therefore have better grasp in handling/using EAs.

Friday, July 3, 2009

Only FIFO orders NFA - no placing of stop loss or takeprofit

So we had a break from the implementation of the FIFO rule by NFA, deferred till 31 Jul 2009. See this note from NFA. Why do we need more time to have this new rule implemented?

Well, it is not just a simple first-in-first-out handling of orders. It also means you cannot put stop loss to your orders!! Essentially, a stop loss is an opposing order and you are not allowed to issue this order in advance.

Imagine you place two orders in the same direction (because you can't place opposing orders anymore ie no hedging). The first order you have a Takeprofit of say 100 pips. The second order you have no takeprofit or stoploss. You trail the second order such that the second order will be taken out say with a trailing of 30pips. But it does not work like this anymore. The first order must be closed first before the second ie FIFO. So as a result, you cannot place takeprofit or stoploss levels now because the first order must always be processed first.

Ok, the brokers in US are coming out with solutions like OCO (One Cancel the Other) which means you can still place stoploss or takeprofit via OCO.

What does this means for EA users? More reprogramming required, more testing needed but little time left.

So what are the brokers with MT4 platform doing:

1. Broker1 - use different lot sizes so that the orders are treated differently
2. Broker2 - drop MT4 becasue it cannot be changed to handle new ruling; so use another platform or use UK broker
3. Broker3 - still not a member of NFA

PS: Remember, all this applies to US brokers only.

Wednesday, June 24, 2009

Looking for the grail in commercial EAs

What is a commercial EA? It is one that you have to pay to use it, whether a one-time fee or by subscription. So which are the ones that one should go for? Well, there is a fourm you can go check out on Facebook Finding the Best Forex Expert Advisors. These people spent their time experimenting with different EAs, and many are with live accounts. So if you need a good gauge of an EA’s performance, then hear from the ground.

The truth about forex is – you can’t predict the future. You can only guess with certainty based on patterns, technical analysis, fundamentals, news, etc.

Have you ever heard someone said – if I sell, I got stopped out and should have long. But if you long, the same happens and you still get stopped out.

What am I getting into. The market does not wait to be predicted. There are many EAs with different strategies. If you lose money it is easy to blame the EA you have just bought. If you win, you think everything is fine and continue until your equity starts to ebb. Every commercial EA get to be called “spam” because either they are really spam or did not meet your profit making criteria when used at that point in time. Almost every EA you read in the forum has followers and non-followers.

Some EAs are expensive, some are cheap. Does a more expensive EA brings better performance?

Thursday, June 11, 2009

MQL5 – a step further for traders

MQL5 is the new programming language MetaQuotes is working on to replace MQL4. MQL5 is similar to C++, whereas MQL4 is similar to Pascal. What this means is that functional programming with languages like C, Pascal, Basic and Fortran has now evolved to object oriented programming using C++, C#.

What is object oriented programming? Well, if you design your program based on objects and then use “methods” to operate on them, you get a cleaner program and your codes are reusable. Also you can get to work on objects rather than a spaghetti of functions. What are objects?

Let’s say you have a table. You define the features of this table: what is it made of, how many legs, what kind of shape. This table object now can be used or operated upon using methods. Methods are really functions. For example you can have a function Place(A,Table), which places another object A (say a plate) on the object table. You can see now that both objects are reusable for other occasions.

I had a quick look at Tetris, a program written in MQL5. Well, EA programming is getting harder and many will find it moving beyond their reach. What traders want are simple tools to automate their strategies and not develop complex programming structures to meet their trading needs. Most of these complex EAs are using more sophisticated algorithms eg neural networks. Today, most people who use NN tend to have them written in C++, trained and optimised. Then when it comes to trading, a simple routine to take parameters from a file as output by the C++ program for use in trading. You can do that all at one go now with MQL5.

But that is only a small percent of traders. The majority just need a simple tool. Most retail traders will be able to pick up MQL4 overtime, after looking at many EAs and templates. But MQL5 is going to be a chore, a pain, and I am beginning to want to yawn at yet another language, another learning curve, rewriting EAs … when all we want is just to make money from forex trading!

Oh I have not talked about MT5 which is the client platform for which will use MQL5 language. MT5 promises better features, better tester, better debugging – anything better is always a welcome. But I hope MetaQuotes will continue their user-friendly platform in the likes of MT4, which is the reason for my preference to choose only brokers that offer MT4. No one has seen MT5 yet, so let’s hope it is for the better.

Thursday, June 4, 2009

Automated Trading Championship - wetoea after ATC2008

What is life for wetoea after ATC2008? It took me a while to figure out how to solve the gapping prices, and finally take wetoea for a run at FXDD because this broker has the same server time as ATC. Here's the results so far, pretty decent isn't it?








Started on 31 Mar 2009, the results above is at 24 Apr 2009, with a total trades of 16. Starting equity is $3,000 and it has a decent profit of $1380. Not bad for a month with a return of 46%. Maximum drawdown is 5.5%.

I will let it run autopilot and see how it goes. Unfortunately demo accounts at FXDD is not forever unlike some other brokers. That's it for ATC2008.

Thursday, May 28, 2009

No more hedging orders NFA – list of MT4 brokers you can’t used

So there are 14 forex brokers left in the US that are registered with NFA, according to what I read here. Back in Oct 2008, there were 29.

Of the 14 US-brokers registered with NFA, a good number of them had introduced MT4 platform. Many months back, there were fewer. Here is a table to list which of these brokers have MT4 and which do not have MT4 platforms.

NFA registered FX brokersPlatformsUK Operations with MT4
IBFXMT4
FXCMMT4, Trading Station, Active TraderYes
MB TradingMT4, MBT Navigator
AlpariMT4Yes
PFGMT4, Best Direct, FX Express, ProTrader
GainMT4, ForexTraderYes
IkonMT4, Tradeview
OandaFXTrade, FXGame
Forex ClubExpressFX, ClassicFX
CMS FXVT Trader
GFTDealbook360
FX SolutionsGTS
IG MarketsPureDeal, L2 Dealer
Easy Forex

Some questions on your mind:

1. What about others not in the list eg FXDD? The answer is: they are not registered NFA members (yet).

2.What about this-and-that platform that xxx-broker has? This is not a comprehensive list. I just want to highlight those who have MT4 platform and with the no hedging rules by NFA, you can’t execute hedging on MT4.

3. What about no hedging on other platforms besides MT4? I have no idea because I only use MT4. But it should apply nevertheless.

4. Why talk so much about MT4? It is the fastest growing platform, with the most number of forums on it. It is also an easy-to-use platform and many are attracted to it because of the Expert Advisers (EAs) you can write to automate your trading strategy. Read more here.

5. What is the last column for? Well. if you must hedge and you are stuck with MT4, get out of the US and go somewhere, like in column 3!

Lastly, I am not a customer of every single broker listed here, and so my knowledge of them is based very much on what you can find and read on the Internet and their websites.

Thursday, May 21, 2009

No more hedging orders NFA – danger of multiple EAs on one account

So you can’t hedge now with US-based brokers of NFA Rule 2-43b. What is also means is that you should not run multiple EAs on the same account if the EAs trade using the same currency pair.

Yes, in the past you can differentiate your orders based on the MagicNumber provided by MQL4. You can even differentiate further using the OrderComment() or some other means. Metatrader will be able to tell which order came from which EA and even be programmed to be independent of each other even though they are running on the same account.

But with this restriction of Rule 2-43, you can’t do multiple EAs anymore unless your EAs operate on different currency pairs. So EA traders, watch out.

Monday, May 18, 2009

No more hedging orders NFA – tales of three brokers

Today is the dateline to implement the new NFA rule for no hedging. Judging by how three leading US brokers have reacted to and implemented the NFA Rule 2-43, the chaos created by NFA and loss of retail forex business for US will be felt for some time. Let’s see what they did and let’s see if you can identify them.

1. The obedient and filial broker – this broker is filial to NFA and follows everything to the core; not only have they implemented the rules, they have done it even earlier than the dateline. And what they have done is to reinforce that hedging is forbidden and many other strategies cannot be used. There are no other solutions and the only way  forward if you still need to hedge is to leave this broker.

2. The rebellious but creative broker – this broker said they are planning innovative ways to circumvent the whole situation; unfortunately there is not enough time. The dateline to meet the obligations was 18 May 2009. And this creative broker managed convince NFA to wait and WILL NOT make any changes for now.

3. The insightful and entrepreneurial broker – this broker is entrepreneurial and had already expanded overseas. Their solution is the best and simplest – go do it outside USA where NFA has no jurisdiction! Their solution is the best because they get to keep all their customers.

So who are these brokers?!

Thursday, May 14, 2009

No more hedging orders NFA – delaying FIFO implementation

In my previous entries, I have mentioned that the First-In-First-Out (FIFO) processing of orders is part of the new NFA Rule 2-43b requirement. And looking at how some brokers have implemented the new rule, it seems that the FIFO requirement is not required.

Well, the truth is NFA has agreed to delay the this FIFO requirement until 31 Jul 2009! Read their notice here.

So there is no running away from it. Time to recode a number of routines.

Monday, May 11, 2009

No more hedging orders NFA – first look from the first broker

The changes expected when the NFA Rule 2-43b will be implemented from 15 May 2009 are as follows, in order of certainty.

1. No buying and selling on the same currency pairs for market orders.

2. No buying and selling stops or limits on the same currency pairs that is in opposite directions.

3. Allowing multiple orders of the same currency pairs for the same type of orders.

4. As a result of point 3, First-In-First-Out processing of orders.

We have a frontrunner broker as of today who have started implementing the NFA 2-43b. The first three points mentioned above has been implemented but not the fourth point. So hedging refers to all opposing type of orders ie be they market or pending (stops or limits) and these are disallowed. If you choose to place orders in the same direction, you can do so with market or pending (stops and limits). And when you close these orders, it can be in any order.

One of my burning question is : what happens when the buy stops and sell stops for the same currency pair is such that if they are ever triggered, they will be stopped out first before the opposing order is triggered. And the answer now: disallowed.

Thursday, May 7, 2009

No more hedging orders NFA - Grid Hedge

What is a Grid Hedge Strategy? First you determine a starting price point. From the this price point you built a series of buy trades above this price point. Simultaneously you do the same with sell orders below this price point.

Usually the orders are placed equi-distance from each other. The variations come with different or same lot volume for each trade order or the number of grid points you want to have.

The key to grid hedging is not having stoplosses for the orders. Having a stoploss will affect the performance of your grid significantly. The example below has a setting of GridStep= 20pips, GridNo=20 for a eurusd backtest from 1 Jan 2009 to 28 Apr 2009. The first chart has no stoploss while the second has a stoploss fix at 50 pips.

gridhedgenoSL

Fig. 1 - GridHedge with no stoplosses

gridhedgewithSL

Fig. 2 -GridHedge with stoplosses

With no stoplosses, the strategy over the stated period achieved a profit factor of 3.8. With stoplosses in place, the profit factor is only 1.1.

The Grid Hedge can also be combined with different stoploss and takeprofit techniques, but suffice to say that it requires the buy and sell orders to float in the system. That is the key to success for GridHedging.

No more using of such strategy for NFA brokers!

P.S. This strategy is not everyone’s cup of tea. It requires a high drawdown to survive the ups and downs of prices until the required profit target is reached.

Tuesday, May 5, 2009

Automated Trading Championship – Will not be held for 2009

There will be no ATC2009! MetaQuotes said in their website that they would like to concentrate on releasing MQL5 this year and hence the Championship this year is cancelled. Instead, they will hold the Championship next year based on MQL5.

And what is MQL5? Another language to learn, EAs have to be rewritten and  more about MQL5 in future entries….

So this is it, no more blog entries on this topic except one last one to share the results of wetoea after ATC2008.

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

Thursday, February 26, 2009

Using Expert Advisors To Evaluate Your Trading Psychology

In my first blog entry on this series of articles on the uses of expert advisors, I mentioned how EAs can be used to research trading strategies. I would like expand this topic and discuss about trading psychology.

Scenario A: Seething Courage to Carry On
One thing for sure: if you trade with real money versus demo accounts, your whole trading psychology will change. What you dare to do in a demo account, you may not dare to execute live. For example, you have a strategy to average in your orders. You take a buy order but the price moved against you. You take another buy order, hoping to average your price entry. Meanwhile the strategy advocates no stop losses for you entries. When you run it off the Strategy Tester, the results show a profitable strategy. But when you eventually run it live, you may not stomach the drawdowns, and wondered how many levels you need to go before the prices come back. You pull the plug - aha - human intervention of a EA - is that good or bad? Let's not answer this question for now. But the point is this - if you execute orders against a trend, and your orders have no stop losses, how would you behave in live trading against a backtest or even demo account?

Scenario B Seeing the EA through.
Suppose a backtest of a trading strategy over a year period, say 2008, showed a not so profitable period but eventually it ended with a nice profit It is comforting to start off with your EA making profits but what do you when your EA makes a string of losses? Do you carry on or do you stop the EA? The graph shows an EA performing well for a period and then becomes non profitable (period 262) and finally coming through at end with a nice profit. Great graph to look at. But how do you behave during the one year period rather than a few seconds or minutes of simulation?

Scenario C: Seeing is Believing
Or you were told that Metatrader's Strategy Tester is useless and inaccurate. Suppose your EA showed such a negative performance in the Tester, would you go ahead and trade it live? If the Strategy Tester is lying when you get good graphs, how much lies are you getting from a downward spiralling profit graph?

Scenario D: The Seeing Leads the Blind
Neural networks are getting popular these days for forex trading. One thing about NN systems is that you need to do some optimisation because it is a pattern recognition system and hence as new patterns comes over a new period, the software needs to be trained. During demo, you watched the EA fire orders, and you have no idea how it figured out when to send an order and when not to. During live, the same thing happened. When it makes money for you are fine! When it loses, what do you do? What have you learnt about trading from such a strategy? Nothing! Is that what you want? If so, then neural network-based EA are for you.

I hope you have a flavour to look out for what your heart tells you.

Thursday, February 12, 2009

Using Expert Advisors for Non-Trading Purposes

Expert Advisors have been traditionally set up for some form of trading, but they are computer programmes after all. That means, they can do almost anything you want. I shall cover one interesting use.


You don't have the luxury of time to sit in front of a computer the whole day. You have gotten hold of some interesting indicators which you would like to try out. How can you study these indicators which get refreshed and repainted as the price ticks come into your charts.


MQL4, the computer language for programming EAs in the metatrader platform has a function called WindowScreenShot that allows you to capture a snapshot of your computer screen and store it as a picture file. If you capture a series of these pictures over a period of time, you would be able to have an idea of what has happened with your indicators. Better still run it off some software (eg InfranView) that allows you to string the pictures into a video.


Where can I find such an EA? Go get it from this article, "A Non-Trading EA Test Indicators".


As you can see, using an EA is not always about trading. It is about helping you do your trading better. Have fun!

Thursday, February 5, 2009

Using Expert Advisors Interactively with Your Chart for Trading

How would you like to look at a chart, draw a trendline, and enter a trade when a certain condition is met and have the EA issue the order and managed it? Well TrendMeLeaveMe by waddahattar is one of the most innovative uses of an EA that I have come across.


As simple as that, by drawing a trendline and naming the trendline "buystop" or "sellstop", the EA will monitor the prices and when it hits the trendline, a stop order will be issued with the specified TP and SL This is certainly a neat tool to put into your list of arsenal.


Or try a variation of this by dreamer3 called MTrendLine. After you have placed a pending order, draw a trendline and name it after the ticket no of the pending order you have just placed. The pending order get modified according to the trendline direction. Very similar to TrendMeLeaveMe but you get to issue the pending order first for MTrendLine whereas TrendMeLeaveMe will isssue the pending order for you. Both will modify the pending order price level according to the trendline drawn.


Hope you are intrigued by this method of doing your trades especially when you are the type the uses this kind of strategy.


One important point though. Look through the codes of these EAs, test them out, and demo them. You might find some faults with their implementations and you may need to correct them before going live with them.

Thursday, January 29, 2009

Using Expert Advisors for Trade Management

In a trade execution process, there are a few steps to follow: 1. wait for the signal; 2. enter your orders; 3. set your exit points ie takeprofit and stoploss, if any; 4. Or do a manual close when it is time to exit.

So if you have an EA that handles the entire process, it is robotic trading or fully-automated trading. Like I mentioned in the last blog, if you are still hunting for the "Holy Grail", then take time to use EAs for managing your trades ie semi-automated. For example, you can choose to enter your trade manually and then let an EA take over the exit. You can have trailing stoplossess or moving takeprofit levels. There are many EAs out there that are free, some are generic and some exhibit certain closing criterias. A good one to use is MTPv1.5 by Stockwell Taylor.

Or you might let your EA hunt for signals and enter a trade for you. Then you manage the exit manually. But usually in this case, if you have your EA fire your orders, you might as well put in the exit conditions for your trades.

So there is this aspect of using EAs for semi-automated trading that adds to your arsenal of tools besides the indicators for technical analysis that we are often familiar with.

I have shared all these ideas in a forum at a Singapore Automated Forex Trading Meetup in greater details with examples. I will document more of this in this blog.

Thursday, January 22, 2009

Using Expert Advisors (EAs) for Strategy Research

Trading has been made so much easier with the advent of computers and Internet. Now the rage is automated trading, algorithmic trading, robotic trading, to name some of the terminologies that has been used. the idea of a robot doing all the trading for you is so compelling that the search for this "Holy Grail" where it is like an automated teller machine, ringing in cash day-in and day-out for us is just irresistible. If you are like many searching for this "Holy Grail", you might want to consider other uses of EAs in the mean time.


Forex trading using the metatrader platform has gained popularity in recent years for many reasons. First, the software can be downloaded for free, along with extensive tools. Second, there is a large community discussing trading strategies with willing coders to develop the EAs, so there are many free EAs out there. Third, the metatrader platform is user-friendly, and somehow, is an easier platform to use. Fourth is the availability of no timelimit demo accounts from a number of brokers. This is especially important for longer term forward testing of your strategy.


EAs are important tools for us, and the more we know how to use them and better still develop them, the better will be our trading. I am sure we have at some point thought of some wonderful strategies and spending time to refine it by trial and error. Why not just code it into an EA and let it run 24x5 and see how your strategy performs. Or you came across a strategy you learnt from a forum ; you can then research deeper into this strategy with the help of an EA. Or test your own trading psychology to see if the strategy is your cup of tea. For example, some strategies requires high drawdown, and it may not be everyone's comfort to stomach high drawdowns or even have the capital to allow high drawdowns. So besides checking out your own strategies, you can explore others and incoporate those that suit your temperament and budget!

Tuesday, January 20, 2009

Why another blog on forex?

This is my first blog on forex, and in particular my thoughts on the strategies and what I observed, researched and experienced especially with the help of expert advisors or in more plain words, computer programs written for trading, whether it is fully automated or semi-automated.

This blog will not be another "how to do it", "where to find what". Instead, it will largely journal what I learn and experience as a result of using such tools in a more-informed and more-equipped world through infocomm technologies.

So how can these technologies help in one's trading? I will pen these thoughts in the next blog.