Posts Tagged ‘automated trading’

Disadvantages of expert advisors

Friday, January 15th, 2010

Following on from my advantages of expert advisors post here are some disadvantages of trying to write and use expert advisors.

Curve fitting

Because it is easy to backtest expert advisors many times with different parameters it is very easy for them to suffer from curve fitting.

Curve fitting means that the EAs are highly optimised for the specific period of time for which they have been tested against, but may turn out to be loss making if run on actual live data.

A good expert advisor will not need to be micro-optimised in order to make a profit. There may well be certain values that perform better than others, but a range of values around the optimal ones should also be profitable to prove that the expert advisor isn’t just working because of some very specific circumstances that are unlikely to occur again in future.

As well as curve fitting the parameters it is very tempting to add new code branches into the expert advisor to filter out bad trades and allow though good trades. Again this is likely to produce an expert advisor which is highly optimised only for the historic data on which you are testing it.

Curve fitting over-optimisation is a very easy trap to fall into when writing expert advisors. It is a waste of time, as you won’t end up with a profitable expert advisor. Spend that time on writing quality expert advisors which can handle whatever data you throw at them.

Unrealistic backtests

Many pieces of trading software that allow you to backtest EAs do not allow you do it in a way that realistically simulates the real market. Doing so would be very difficult because there is a lot more information you need to know other than the price. E.g. you need to know about the spread, execution delay, slippage, and liquidity.

Backtesting data does not tend to give you access to this kind of information. In addition the granularity of backtest data is often much less fine than what you would get if you were trading live.

Most backtesting data is only available for 1 minute and above timeframes. This means that you miss out on the tick-level information that could be essential, especially if your trading strategy works on shorter timeframes.

Many backtesting software packages compensate for this by ‘filling in the gaps’, and create simulated ticks. This can be dangerous, as the algorithm used may well not generate ticks in a way that is realistic enough for your strategy.

It is quite possible (in fact easy) to create an expert advisor that works brilliantly on historical data using a backtest but consistently loses when used for real.

Difficult to write

Translating a working strategy from your brain into an expert advisor can be very difficult.

When you trade manually you can interpret huge amounts of data and news in a way which can be very difficult for a computer program to do. Interpreting simple facts such as the value of an indicator is easy for an EA to do. However interpreting something such as the current economic climate or the latest news that has just been released is extremely difficult.

Getting EAs to recognise complex chart shapes and patterns can be very difficult. It is all to easy to program the EA to recognise specific patterns that occurred in the past rather than getting it to understand the meaning of the chart patterns in the way that your brain will.

Expert advisor bugs

All software beyond trivial code snippets will contain bugs. For most pieces of software the consequences won’t be too bad. Maybe the program will crash, get stuck, or if you are unlucky perhaps you will lose some work.

Expert advisors for forex and CFDs are somewhat different as they have the power to make decisions that affect your bank balance! If your EA has a bug then it could make the wrong decision resulting in a loss of money. If the bug is bad then maybe you’ll lose a lot of money!

Would you trust a piece of computer software to buy and sell on your behalf? Even if you have done large amounts of testing how can you be sure that your EA won’t trip up when it is left to run by itself?

As EAs are often left to trade by themselves, any bug or defect in the code could be very costly. You might not spot that anything is wrong until you find your account has been emptied of all its money.

Think carefully before you let an EA lose on your live account. Make sure it is well tested, and keep a careful eye on what it is doing. To avoid it losing too much in the event that it doesn’t work as expected make its trade sizes small to start with and don’t keep to much money in your account.


Before you spend time creating an expert advisor make sure you don’t fall into any of the problems listed above. Doing so could cost you serious money.

The Expert Advisor advantage

Monday, December 21st, 2009

For most people trading in forex is a very manual process. It involves watching charts, indicators, and the news. They then have to work out in their head whether it is a good time to buy or sell.

For some strategies this makes a lot of sense. For example if you trade based on news events then you need to be there to interpret how the news will affect the price. This is fundamental analysis.

Many forex trading strategies rely on much simpler decisions. If you are basing your trading decisions on the shape of the chart, or on the values of your indicators then you are using technical analysis.

Many technical analysis strategies work by making decisions purely on indicators or price.

For example a strategy might be to buy if the price moves above a certain moving average line and sell if the price falls below the line.
Another strategy might involve buying or selling based on one or more technical indicators such as MACD, parabolic SAR, or RSI.

If your strategy is based on simple rules such as certain technical indicator values being reached then you may find that your trading is very robotic. You wait for a specified event to happen and then you act on it in a predefined way.

If you have a strategy that sounds like this then it could be a very good candidate for automating – i.e. creating an expert advisor to do the trading for you so you don’t have to do it yourself.

metatrader mql4

Expert advisor code in MetaTrader

This post will look at the advantages of expert advisors.

Expert advisors don’t get tired

If you are trading manually then the amount of time you can spend trading will be limited by how long you can concentrate or stay awake.

Forex is a 24 hour game with trading opportunities right around the clock. If you are trading manually then you are limiting yourself to only taking advantage of a fraction of these opportunities.

Throughout the day you will also need to take breaks for food, drink, to answer the telephone, etc. During one of these breaks something might happen which you don’t see until it is too late. This could cause you to buy or sell at a bad time, or miss out on a great trade altogether.

An expert advisor will be able to trade for you right through the night, through your lunch break, and when you are out of the house. It will never get tired and so will be able to capture all the trading opportunities that it is programmed to capture.

Of course if the expert advisor is doing your trading for you, then you will have more free time to do more important things like reading a book, or seeing your friends. Who wants to spend their life staring at a moving line on a screen, or watching numbers going up and down?


A lot of people have sound trading strategies but they fail to stick to them. You may find that your emotions get in the way and cause you to sell too early, or buy too late, because you don’t have the confidence to stick to your trading plan.

It is also possible for you to get stressed when trading which could lead to you making mistakes in your trading. How many of us have sold when we meant to buy, or entered the wrong amount into our trading ticket and then had to accept a loss in order to get out of the trade?

Once it is correctly programmed an expert advisor will have no such problems. It will follow your simple set of rules (or maybe a complicated set of rules!) without ever hesitating or letting its emotions cloud its judgement. Obviously an expert advisor is just a computer program so it will just do what it is told to.

This consistency means that it will stick perfectly to your trading plan and will never diverge from the rules that it has been given. The expert advisor won’t make mistakes – if it is supposed to buy then it will buy – it won’t press the wrong button and sell!

Speed of analysis

Human brains are great for many things, especially ‘fuzzy’ processing like thinking, and interpreting inputs from complex senses such as sight and sound. What they aren’t so good at is number crunching, or making decisions based on large amounts of data that are coming in at the same time.

If you are a manual forex trader then you will probably limit yourself to trading one or two currencies simultaneously. Trading more than this can get confusing. For one thing keeping an eye on multiple charts can be difficult, and if significant events start happening with multiple currencies at the same time (as they often do) you may not be able to keep up.

An expert advisor has no such problems. It can handle trading simultaneously in 10 different currency pairs just as easily as it can handle trading with one currency pair. Computers are able to process information so fast that they have no trouble keeping up with what is going on with multiple price feeds.

If you have a strategy that is applicable to multiple currencies then an expert advisor could allow you to trade more currencies simultaneously than you are able to using manual methods. Alternatively it can watch multiple currencies and then pick the best one to trade in. Imagine how fried your mind would get if you were trading in a short time frame and trying to keep your eyes on 10 charts!


Coming up with a manual trading strategy may involve eyeballing many charts and evolving the parameters you use over time.

If you write an expert advisor then you can very quickly test your strategy over many years worth of data in just a few minutes. This will give you a much better idea of how well your strategy will perform than just eyeballing the charts.

Trying to gauge how well the strategy will work using your eyes and brain is very dangerous because of hindsight bias. You may be feeling optimistic about your strategy and without realising it your brain will focus on areas of the chart where your strategy would work and will filter out parts of the chart where you would make a loss.

An automated backtest will get you much more accurate and consistent information on the performance of your strategy.

And because you can quickly test your strategy over many years worth of data you can also re-test your strategy using different parameters. You may think your strategy works best using a 11 day moving average, but some simple testing could reveal that a 13 day moving average is in fact the most profitable.

Are automated expert advisor the answer?

Expert advisors sound great don’t they? For many strategies then can prove to be much better at trading than a real person would be. They aren’t perfect though.

In a future post I’ll be looking at the disadvantages of expert advisors, and I’ll also be writing further about other issues to do with expert advisor.

If you want to have a go writing your own expert advisor you can get a MetaTrader forex account for free.