Русский 中文 Español Deutsch 日本語 Português
An Expert Advisor Made to Order. Manual for a Trader

An Expert Advisor Made to Order. Manual for a Trader

MetaTrader 4Examples | 15 February 2008, 08:48
12 975 12
Andrey Khatimlianskii
Andrey Khatimlianskii

Introduction

Not all traders are programmers. And not all of the programmers are really good ones. So, what should be done, if you need to automate your system by do not have time and desire to study MQL4? Usually one visits the forum and creates a topic named something like "I need a programmer":

This article is written specially for those who need help in writing an Expert Advisor. You will find here the contact information of EA-writers, recommendations on contacting them and descriptions of the most frequent problems.


What Should Be Done Before Ordering an Expert Advisor?

Before starting to look for a programmer, make sure that your strategy is profitable. Do not pay for an EA that will not bring profit. You can make it manually by looking through historic data or by trading mentally, which in fact is quite difficult. It can also be done using a manual tester described in the article Testing Visualization: Manual Trading. The most true results can be acquired by trading on a demo account or a mini-real account, but this requires more time and, probably, money. While testing a strategy, note that:

  • market constantly changes and a correct behavior of indicators on history does not guarantee their being adequate in real trading;
  • some indicators draw signals on already formed bars. Successfully placed arrows on price extremums belong to history. In real trading they will become visible only after several bars. For example, signals by Fractals are shown with a two-bar delay. You can use it, but taking into account that you will enter the market not with the fractal, but only when two more bars are formed (on an hour chart it will be in two hours). Do not use indicators, whose algorithm of operation is unknown to you. This may lead you to bad results;
  • there are a lot of indicators, which intentionally or not look into the future. For example, the simple Moving Average with a negative shift will in due time show market pivots. But only on history...

Many errors of this kind can be detected by way of testing a strategy in real-time mode on a demo-account. But this seemingly reliable check cannot guarantee a total coincidence with real trading, because demo and live accounts have some differences:

  • speed of order execution on a demo-account is always higher than that on a live account. Be ready that you live position will be opened only in several minutes after you send an order. This won't influence results of a long-term strategy, but will fully spoil your daily trading;
  • on a live account trade conditions (spread, distance to stop-orders, margin-call level etc.) can be change during trading. For example, prior to news releases or before holidays. While testing your strategy on a demo account, you can hardly face such surprises, but don't forget to take them into account when estimating the effectiveness of your strategy.

And do not forget that real money are real money and attitude to them differs from that to a demo account. An Expert Advisor can eliminate a large part of emotions from a trading process, but it cannot fully eliminate your possible errors. Trading on a demo account, stick to one strategy, do not change your plans and do not make emotional decisions. Your future EA is only a program and it will work according to strict rules. If you want to know what results your EA can achieve, you trading style must be the same as that of an EA - concise and disciplined.


If after all these checks your strategy still shows quite a good profit, enough to cover all the surprises of a real trading, you may move to the next stage - formalization of an algorithm.



Algorithm Formalization

If you have been trading using your strategy long enough, it will be easy for you to formalize an algorithm. All you need is to list rules, according to which your EA should trade.

Note that the program will be written by a person that does not have the faintest idea of your strategy. You should specify all the smallest details: parameters of indicators, distance to stop-orders, maximal number of opened positions, trailing stop algorithm, etc. Your requirements specification must contain the description of the reaction on each significant event: activation of a stop-order, appearance of a repeated signal when a position exists, start of an EA after disconnection etc.

You should understand that your PC cannot guess, assume or make independent decisions, - it simply trades according to our rules. If a situation occurs, the reaction on which is not provided by the algorithm, your EA will do nothing.


Let us see on an example what can happen if a requirements specification is not very concise or detailed. The following dialog demonstrates the process of EA development by a Programmer according to the algorithm by a Trader. I intentionally displayed absurdly silly characters. This will emphasize the attention on errors. For a better understanding you can download examples of all EAs and test them together with the Trader.


Trader:

Hello! I want to order an Expert Advisor.
It should open positions when MA(9) and MA(18) cross.
If a quick one crosses a slow one upwards, a Buy-position should be opened. If vice versa - a Sell-position should be opened.
How much does it cost?

Programmer:

To define the cost I need a concise and detailed requirements specification.
Approximately - $25.

Trader:

I have written everything in the previous letter!
There are two moving averages, when a quick one (with the period 9) crosses a slow one (with period 18) upwards, a Buy-position is opened. When vice versa, a Sell-position is opened.

Programmer:
Ok, clear.
Here is your Expert Advisor - Sample_1.mq4.
Trader:

What have you written?! This is not an EA!
Why are there so many open positions? Why aren't they closed?
Are you really a programmer or what?

Programmer:

The number of positions is equal to the number of crossings. Test your EA in the visual mode, you will see everything - a position is opened at each crossing.
If the crossing is upward, a Buy-position is opened. If it is downward, a Sell-Position is opened.
You specification does not contain a word about position closing.


Trader:

I forgot to tell you: if there is an open position, it should be closed at a contrary crossing - only one position can be opened in the market at a moment. And for each opened position a Stop Loss should be placed at a distance of 50 points.


Programmer:
See the second version - Sample_2.mq4.

Trader:

Why is here an open Buy-position? Here is no crossing!



Programmer:

There was crossing, but it has disappeared. The chart reflects indicator values on already formed bars and you can see their changes in a bar development process only using a visual testing mode or in real operation. Believe me, there was an intersection at the moment of position opening.
If you wish, we can make the EA so, that positions will be opened upon the signals of formed bars. In such a case all signals will be visible on a chart.
Many traders do the same.


Trader:

Let's try.
And can I optimize parameters of moving averages and values of Stop Loss and Take profit levels?


Programmer:

Here is the third version - Sample_3.mq4:
- search of signals is done on formed bars (1st and 2nd);
- parameters of moving averages and values of Stop Loss and Take Profit are specified in external variables.
Check it.


Trader:

Now it resembles what I really wanted.
But when I start several EAs, only one of them trades. And sometimes they close each other's positions!


Programmer:

In the fourth version (Sample_4.mq4) I added division of orders according to the magic number. If you start several EAs on a chart of one symbol, set different values of the variable MagicNumber for each of them.


Trader:

Now it is really ok!

So what must be the requirements specification, according to which a Programmer could create the fourth version of the EA at the first time? Let us try to formulate requirements to an Expert Advisor:
  • The EA should control only its own positions and shouldn't deal with positions opened manually or by other EAs.
  • If there are no positions opened by the EA:
    • if the quick MA crosses the slow one upwards, a Buy-position is opened;
    • if the quick MA crosses the slow one downwards, a Sell-position is opened.
  • If there is a position opened by the EA:
    • if it is a Buy-position:
      • if the quick MA crosses the slow one downwards, the Buy-position is closed and a Sell-position is opened;
    • if it is a Sell-position:
      • if the quick MA crosses the slow one upwards, the Sell-position is closed and a Buy-position is opened.
  • Parameters of the quick and the slow MA (period, drawing method, used price) must be set by external variables.
  • Indicator values are taken from a chart period, on which the EA works.
  • For the intersection detection the first and the second bars are used.
  • Position size is determined by an external variable.
  • When a position is opened, StopLoss and TakeProfit are placed at a distance determined by external variables.
  • There should be an option of disabling StopLoss and TakeProfit.
  • If an error occurs, the EA should display a window with the error information and retry the attempt on the next tick.

This is the simplest task. Such simple systems are very rare in real life, so pay attention to all the details when creating the list of requirements.


Undoubtedly, such silly Traders and Programmers are very rare. But, believe me, they exist. It is better to indicate even seemingly obvious details, than later argue with a programmer.

The last thing that can be done before searching for a programmer is trading according to a "list of rules" - when trading do only what is written in this list. Thus you will see all the details that could be omitted when formalizing the algorithm. This may prevent you from possible payments for the improvement of the EA.


Choosing a Programmer


For several years of the existence of the programming language mql4, there appeared quite a lot of Expert developers. Many of them are constant visitors of the website mql4.com. They post here their own developments in CodeBase, write articles and communicate in the forum helping newbies and improving their own skills. Many of them have live accounts and trade both using an Expert Advisor and manually.

There are no (at least I haven't seen any) data bases of EA developers where one could get all the necessary information about a professional MQL4 programmer. And one can hardly create such a data base, because many of EA writers stay in this business not so long.

This article is aimed at helping you to find a programmer. In Appendix 1, Contact Information of EA Writers from mql4.com, you may find all the available information.

When choosing a programmer for the implementation of your Expert Advisor:
  • consult your friends - traders who have already worked with EA writers;
  • read the forum topics about implemented/non-implemented EAs;
  • see profiles of authorized users - many of them leave information in their profiles;
  • contact programmers personally - via email or ICQ.
Prices and working conditions may differ. Some of them work on a pre-paid basis and do not send you the source code until they receive the whole payment, others may send you the ready code as a "present" relying on your honesty. There are EA writers that will not give you the source code attaching the EA only to one account. So, clear up all the details before making your decision.

Communicate, negotiate. There are a lot of variants, choose the right one.


Testing an Expert Advisor

After you discuss work conditions and approve the algorithm, a programmer will write an EA and send it to you for testing. Your task is to make sure that the EA's operation conforms with the requirements specified.

First, test it in a strategy tester using different combinations of parameters - it is the quickest way to check the algorithm. You may open a chart, on which the EA was tested, and check the results visually.


If your EA should act not only at the moment of bar opening, but also during its formation, try to carry testing in the visual mode - you will see the actions of the EA at each tick. You will see values of indicators on the zero (current) bar, shifting and triggering of StopLoss at sharp price movements, etc.

If testing in the strategy tester did not show any mistakes, test your EA on a demo account.

Try to start several EAs with different or similar parameters and trade simultaneously with them. The EA should continue working according to the algorithm irrespective of what is happening. If there are no errors, you may tell the programmer that it's ok and complete the deal.


But very often the first version of an EA contains disagreements with the algorithm, resulting either from the inaccurate description or from an error of a programmer - it is a common situation. Simply contact the programmer and if it is really his mistake, he will fix everything. In your email indicate the following:

  • what is wrong in the EA's operation;
  • EA parameters, at which the error occurred;
  • testing parameters (symbol, period, timeframe, modeling mode, server, etc.) or operation time and server address, if you check the EA on a demo account;
  • extract from the tester journal;
  • several screenshots with the problem description;
  • EA logs ('Journal' tab in the tester or 'Expert Advisors' tab when working on a demo account).
If you include all the necessary information, the programmer will quickly find and fix the error.

Usually cooperation implies technical support even after the EA is ready and payments are done. It means, if an error occurs after a month's operation, a programmer will fix it free of charge. It depend on the way you arrange it.


Conclusion

The automated trading is gaining more and more popularity. Many traders trust the management of their accounts to Expert Advisors or fully automated trading robots. To write such a program one needs special knowledge and experience. Unfortunately not all traders have time and desire to study the special programming language for the implementation of their ideas. This article is an attempt to establish and strengthen the connection between traders and trader-programmers. I hope, this article will result in the appearance of good and reliable Expert Advisors.

Appendix 1. Contact Information of EA Writers from mql4.com

This section contains the contact information of EA writers who are members of mql4.com community. The list is constantly updated, and if you cannot find a helper now, check the list later - probably you will find one. Please note, that anyone can leave contact information here, even frauds. It is almost impossible to check the work quality and honesty of all the EA developers. So after working with any of them (successfully or not), please leave your comment to this article containing your opinion about the person you have worked with - this will help other traders to make the right decision.

If you are an EA developer and want to include your contact information into this list, please send it to me and you will be added. It is free of charge and requires only your fulfillment of your obligations discussed with a trader ordering an EA. If complains about your work appear in the comments to this article and you cannot settle the question within one week, you will be deleted from the list. I hope this will be a rare case.

Nickname Name e-mail Additional information
komposter Andrey Khatimlianskii mql@komposter.me www.komposter.me
komposterius
211-605-801
Mike Michael Bernardovich mikemb [@] ittportal [.] net
315-165-028
Tel.: +79015453588
michal Michal Rutka mqlservice.com [@] gmail [.] com
michal_rut
Tel.: +31614511749

Jan Klimo jan.klimo [@] gmail [.] com Tel.: +420777288782
fuzzbomb Andrew Young advisor [@] easyexpertforex [.] com www.easyexpertforex.com
giaras Giampiero Raschetti giampiero.raschetti [@] gmail [.] com
giaras
5leepless Damian Burrowes sleepless.damian [@] gmail [.] com
Vitovd Witold Wozniak contact [@] mqlsoft [.] com www.mqlsoft.com
vasya_vasya
Vasiliy Orlov pr0baproba [@] mail [.] ru
555-485-590
linx Lin Xie linx_mt [@] hotmail [.] com
linx_mt


MetaQuotes Software Corp. is not responsible for the violation of agreements between a trader and a programmer.

Translated from Russian by MetaQuotes Ltd.
Original article: https://www.mql5.com/ru/articles/1460

Last comments | Go to discussion (12)
[Deleted] | 7 Mar 2008 at 19:23
I'm also having trouble downloading these examples..  If anyone has been able (or can) download them,   could you please email them to me: edwardbaafi [at] gmail.com..  Thanks..
[Deleted] | 5 Apr 2008 at 03:06
I would like to thank you for making everything so very clear. We newbies, needed this, Thanks again.
miki
miki | 19 May 2009 at 05:31
Really appreciate what you have posted here.
[Deleted] | 29 Apr 2010 at 00:52

I had <Deleted> do an EA for me, and I'm very pleased with both the process and the results. I had never designed an EA before, and wasn't sure the best way to explain what I wanted. The whole design process was fascinating. It really is amazing what is involved in putting what seems so clear visually into a set of instructions. Andrey was very patient with me, and was very quick in the adjustments that were necessary. I'm sure that if I decide to do another, I'll go straight to him.

OldZ
OldZ | 5 May 2010 at 12:04

Thank you Andrew,you created a great post !

Easy Way to Publish a Video at MQL4.Community Easy Way to Publish a Video at MQL4.Community
It is usually easier to show, than to explain. We offer a simple and free way to create a video clip using CamStudio for publishing it in MQL.community forums.
Using MetaTrader 4 for a Time Based Pattern Analysis Using MetaTrader 4 for a Time Based Pattern Analysis
Time based pattern analysis can be used in the currency market to determine a better time to enter a trade or time in which trading should be avoided at all. Here we use MetaTrader 4 to analyze history market data and produce optimization results that can be useful for application in mechanical trading systems.
Metalanguage of Graphical Lines-Requests. Trading and Qualified Trading Learning Metalanguage of Graphical Lines-Requests. Trading and Qualified Trading Learning
The article describes a simple, accessible language of graphical trading requests compatible with traditional technical analysis. The attached Gterminal is a half-automated Expert Advisor using in trading results of graphical analysis. Better used for self-education and training of beginning traders.
Equivolume Charting Revisited Equivolume Charting Revisited
The article dwells on the method of constructing charts, at which each bar consists of the equal number of ticks.