Articles by: David Williams

Building Your Expert Advisor

The 3 Metrics to Watch When You Build Your First Expert Advisor

When you start to design and build your first Expert Advisor – an EA that you plan on trading – it’s important to keep a close eye on these three metrics:

  1. Total Trades: The Expert Advisor should trade often enough so that you can quickly evaluate its performance.
  2. Entry and Exit Quality:  Evaluate the quality of your Trade Entries and Exits.
  3. Winning Percentage: The Expert Advisor should win more than it loses.

OK, I realize a bunch of you are shaking your heads and saying “uh, yeah – no kidding, of course it should win more than it loses!

But remember, there are plenty of good, profitable trading systems that lose more often than they win.  Generally, this kind of system will take a small loss if the trade does not move in the positive direction. But if the trade does move positive, this system will allow the trade to run and take a large profit.

So, you end up with a profitable system that closes more losing trades than winning trades.

This kind of system is not ideal for your first Expert Advisor.

Here is an excerpt from my book Automatic Alpha explaining why.

The Ideal First-Time Mechanical Trading System

A trading system should be defined such that (i) its mechanical implementation is straightforward and (ii) its ultimate behavior is easy to understand and tolerate.  A first-time trading system should meet both of these objectives – giving the trader that is developing their first mechanical trading system a good chance of success, both in developing and running the system.

 Two of the most important characteristics of a first-time mechanical trading system are:

(1)     A high winning percentage (greater than 70%), and

(2)     A high number of trades (about one to two trades per week). 

These characteristics are important because a system with a high winning percentage is easy to run.  It wins a lot.  Also, a system with a high number of trades provides a good deal of feedback.  This means a trader can quickly recognize if the system departs from its historical behavior, and make adjustments accordingly.

It’s hard to make adjustments to a system that does not trade often. One to two trades per week is a good number: high enough to provide efficient feedback, but not so high that the trading costs (commission, spread, etc.) become a significant factor.

There are a number of commercially available systems that may be generally profitable, but only trade and only win a small percentage of the time. Some of these systems do not trade often and do not win often, but when they win, they make a substantial profit.  This type of system can be valuable and can be an important part of a diversified trading strategy, but it is generally not a good model for the trader developing and running their first mechanical system.  These systems are difficult to run due to their prolonged losing streaks.  Most traders will be overcome by the urge to stop trading the system. Of course, soon after stopping, the system will often signal a trade for a substantial profit.  The best way to avoid this scenario is to start with a system with a high winning percentage.

As you become a more experience system trader, you may choose to develop and run systems that do not necessarily have a high winning percentage or a high number of trades. But for your first system – to help get started in the right direction and to build confidence – it is a good idea to choose a system with a high winning percentage and a high number of trades.

 

How to Increase Your Winning Percentage

Almost all Expert Advisors can be split into two logical parts.

    1. The Trade Entry
    2. The Trade Exit

The responsibility of your Entry is to get the trade started in the right direction.  That’s all.

The responsibility of your Exit is to get out of a bad trade quickly – or close your profitable trade.

The exit makes all of the money.

Known fact:  If you get the chance to talk with a successful trader, don’t ask her how she opens a trade, ask her how she closes a trade.   Again, your exit is responsible for making your profit.

Many traders, especially when they first start out, worry too much about their trade Entry and not enough about their trade Exit.

Use the Entry Test

If the logic of your EA can be split into its entry and exit, then you can test the Entry separate – without affecting the Exit.  This is a huge advantage.

The Entry Test is simple.  You remove your Exit logic completely, and just exit the trade after a certain period of time, for example 2 hours, or 1 day.  When you look at the results of this test, you ignore the total profit.  You only look at the number of winning trades.

The Entry Test shows you if your entry is getting your trade started in the right direction.  Best of all, you can make changes to your entry logic and use this test to see if the change increased your number of winning trades.

Your Exit

Remember, there are a lot of ways you can exit a trade that are not based solely on a Takeprofit or Stoploss value.   The exit could be based on an indicator, the time of day, etc.

Exits can be very creative. And they are usually worth the creativity.

I can’t say the same for entries.  They can be very creative, but there seems to be a point of diminishing returns as you add more sophisticated criteria to the entry logic.  (The Entry Test can prove this pretty quickly.)

Use the Exit Test

A great way to test the quality of your exit is to look at each closed trade, double how long the trade was open, and locate the highest profit point within the time range.  This would have been the best time to exit the trade.

For example, suppose you bought the EURUSD on Monday and closed the position early Wednesday – so the trade was open for about 2 days.  At the end of the week you would look at the EURUSD chart from Monday to early Friday (about 4 days) and note the highest trading point of the pair (highest because it was a long position, we’d use lowest for a short position).

Obviously, the point in time when the trade was at its highest profit value, within the 4 day period, would have been the best time to close the position.

This is only a rule-of-thumb test – you can vary the holding period – but this test gives you a quick look at how much profit you might have left on the table.  And more importantly, when you are reviewing the chart, you may see something that gives you an idea to improve your exit.

One last point: I’ve found that a trailing stop often leads to a higher winning percentage and a lower overall profit.  This does not sound like a good thing, but since you are trying to experience a high winning percentage with your first Expert Advisor, it might be something to consider.

I hope this information helps you in your quest to build your perfect Expert Advisor. Let me know!

A Nail Gun, a Jack Hammer and Herding Cats

Herding Cats

Yup, it’s true.  I put a 4 inch nail through my left thumb with the ole’ DuoFast pneumatic framing gun.

Here’s a pic.  Don’t worry, it’s not too graphic:

Thumbnail

Ever since I was a kid, I wanted to build my own house. Not sure why.

I’d go through the whole process in my mind.  From the foundation to the roof, step-by-step, building an imaginary house.  Fell asleep many a times with those visions in my head.

My main problem in realizing this dream was money. A bank won’t even consider giving you a mortgage unless you own the land or you’re a licensed builder.

Well, I didn’t own any land and I wasn’t a builder.  

But after a lot of searching, I managed to find a company in California that was willing to lend money to do-it-yourself home builders. Yeah, they charged a big chunk of money for the service, but this was really the only way.

It wouldn’t be easy. I had worked a few construction jobs before I joined the military and again throughout college so I had some experience. But this was different. This was a big project.

It turned out to be a long, tough year. Yup, per the terms of the mortgage, it had to be complete in 1 year!

For the most part, it went pretty well. Still, with a big project like a house, there’s so much detail.

And what I learned was that it’s very difficult to get something exactly right the first time you do it.  

There is a list of things I wish I had done differently. But, unfortunately, when it comes to house-building, it’s not too easy to go back and make fundamental changes.

So why am I writing about this? Well, aside from getting a chance to show off a really cool picture of a nail through my thumb, I’ve found this to be true in a lot of different areas.

It’s hard to get something right the first time.

As a matter of fact, this is especially true with software programming. Software is usually complex, with a lot of details. It’s very difficult to get all those details right the first time.

But the big difference is that it is easy to go back and change software. You don’t have to jack-hammer a foundation.  Just re-write and re-compile.

And when it comes to building an EA, you should expect the same thing. It won’t be right the first time.

I think this fact is actually the best argument for either:

(1) learning MQL, or

(2) using a tool like VTS.

It’s just so much easier to be able to tweak and tune your EA yourself – without having to work with a programmer (like me!).

You know what they say: “Managing programmers is like herding cats”.

Whatever path you choose for your EA development, don’t worry, I doubt you’ll put a nail through your thumb!

NOTE:  I took that picture with one of those disposable cameras while I was driving myself to the emergency room.  I was back to work about 1 hour later.  I’m kinda proud of that!  The truth is I got extremely lucky and did not hit any bone.

Truly, it was merely a flesh wound.