How to Quickly Create an Expert Advisor for Automated Trading Championship 2010

Introduction

In order to develop an expert to participate in Automated Trading Championship 2010, let's use a template of ready expert advisor from The Prototype of Trade Robot article. Even novice MQL5 programmer will be capable of this task, because for your strategies the basic classes, functions, templates are already developed. It's enough to write a minimal amount of code to implement your trading idea.

What we will need to prepare:

Selection of strategy

Writing an Expert Advisor

Testing

Optimization in Strategy Tester

Optimization of the strategy

Testing on different intervals

1. Selection of Strategy

It is believed that trading with trend is more profitable than trading in a range, and the bounce from the intraday levels occurs more frequently than the breakdown of channel borders.

Based on these assumptions, we will open position towards the current trend on the bounce from the channel boundaries (Envelopes). We'll close position on a signal to close position or when the Stop Loss or Take Profit levels will be reached.

As the trend signal we'll use MACD growth or dwindling on the daily chart, and we will trade on the bounce from the channel boundaries on the hour timeframe.

Figure 1. MACD Indicator on EURUSD Daily Chart

If MACD indicator grows on two bars in succession - this is the Buy signal. If it dwindles on two bars in succession - this is the Sell signal.

Figure 2. Price Bounce from the Envelopes Boundaries

2. Writing an Expert Advisor

2.1. Included Modules

The expert will use the ExpertAdvisor class from the ExpertAdvisor.mqh module.

And so, after writing the code, send the resulting expert to Strategy Tester.

3. Testing

In Strategy Tester for the "Last year" period on EURUSD we get the following chart:

Figure 3. Results of Testing the Trading System with Initial Parameters

The results are not impressive, so let's start to optimize the Stop Loss and Take Profit levels.

4. Optimization in Strategy Tester

We will optimize the Stop Loss and Take Profit parameters at the interval 10-500 with step 50.

Best results: Stop Loss = 160, Take Profit = 310. After Stop Loss and Take Profit optimization we received 67% of profitable trades against the previous 36% and net profit of $1522.97. Thus, by simple manipulations, we've upgraded our system to break-even and even got some profit.

Figure 4. Results of Testing the Trading System with Optimized Stop Loss and Take Profit

Next let's optimize the Envelopes period and deviation.

Envelopes period will change from 10 to 40 with step 4, and deviation - from 0.1 to 1 with step 0.1.

This article will teach you how to receive trade signals that are necessary for a trade system to work. The examples of forming 20 trade signals are given here as separate custom functions that can be used while developing Expert Advisors. For your convenience, all the functions used in the article are combined in a single mqh include file that can be easily connected to a future Expert Advisor.

This article summarizes and systematizes the principles of creating algorithms and elements of trading systems. The article considers designing of expert algorithm. As an example the CExpertAdvisor class is considered, which can be used for quick and easy development of trading systems.

This article describes the usage of the TesterWithDrawal() function for estimating risks in trade systems which imply the withdrawing of a certain part of assets during their operation. In addition, it describes the effect of this function on the algorithm of calculation of the drawdown of equity in the strategy tester. This function is useful when optimizing parameter of your Expert Advisors.

Alexander Topchylo (Better) is the winner of the Automated Trading Championship 2007. Alexander is an expert in neural networks - his Expert Advisor based on a neural network was on top of best EAs of year 2007. In this interview Alexander tells us about his life after the Championships, his own business and new algorithms for trading systems.