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.