Home Coding your first expert advisor second part
Basics & Industry, Forex Basics

Coding your first expert advisor second part

If you are looking to automate your trading endeavours or if the emotional side of trading is causing you too much stress it’s a good idea to set up an automated trading system. There are lots of trading platforms out there that allow backtesting so there is no excuse why you can’t test out your trading ideas on past data before you put them to work.

There’s also MetaTrader 4 which will allow you to put your system into an expert advisor (EA). This is an easy way to test your system on the market and see if it will make money. It will also allow your system to trade automatically and even when your computer is switched off, as it connects to the backend of your broker.

Guest post by  FXTM

Set up your trading goals

The first step to creating a winning forex system is to think about your trading goals as these will help you define your strategy. Do you want to trade every day or just once a month? Do you want a strategy that trades several different currencies at once? Do you want a trend following strategy or a mean reversion system? Once you have done this, put your strategy ideas down on to paper, then start converting them to code.

Backtest the system

The next step is to get hold of backtesting software and historical forex data. You will need at least a year in order to gather meaningful results but the longer the better. And don’t forget to include commissions when you do your tests.

Isolate a period of the data for your in sample and another for your out of sample testing. You will be testing all of your ideas and trading strategies on the in sample data and won’t touch the out of sample data until you have a strategy that looks good. This is important, because as soon as you test your system on out of sample data, it will lose its statistical significance.

If you have three years of historical data, it’s a good idea to test your strategy on the first two years and reserve the out of sample data for later on.

Once you have a system that looks good on your in sample tests run it once and only once on the out of sample data. If it still looks good, you have a system that stands up against testing and you may be able to use it on real data. If it doesn’t look very good, you’ll need to start again and go back to testing on your in sample data.

Paper trade

Your system worked perfectly on in sample and out of sample data, that’s good. But, before you start trading it there’s some more steps you need to take. First, try walk-forward testing. That is, start your tests at different periods then follow them through on different out of sample periods.

The next and final step is to paper trade. You need to test this system for at least three months on real, live data before you can be confident it will work.

Further reading:  Coding your first expert advisor – Principles

Yohay Elam

Yohay Elam

Yohay Elam: Founder, Writer and Editor I have been into forex trading for over 5 years, and I share the experience that I have and the knowledge that I've accumulated. After taking a short course about forex. Like many forex traders, I've earned a significant share of my knowledge the hard way. Macroeconomics, the impact of news on the ever-moving currency markets and trading psychology have always fascinated me. Before founding Forex Crunch, I've worked as a programmer in various hi-tech companies. I have a B. Sc. in Computer Science from Ben Gurion University. Given this background, forex software has a relatively bigger share in the posts.