Русский 中文 Español Deutsch 日本語 Português 한국어 Français Italiano Türkçe
Creating MQL5 Expert Advisors in minutes using EA Tree: Part One

Creating MQL5 Expert Advisors in minutes using EA Tree: Part One

MetaTrader 5Trading systems | 1 November 2011, 12:29
21 773 41
eatree
eatree

Introduction

EA Tree is the first drag and drop MetaTrader MQL5 Expert Advisor Builder. It is a windows application that runs locally on your computer. You can create complex MQL5 code using a very easy to use graphical user interface.

In EA Tree, Expert Advisors are created by connecting boxes together. Boxes may contain MQL5 functions, technical indicators, custom indicators, or values. Outputs of one box may be connected to inputs of another box to form a "tree of boxes". EA Tree generates MQL5 code from the "tree of boxes" and then uses the MetaTrader 5 platform installed on your computer to convert the MQL5 code into an executable Expert Advisor.

Figure 1. EA Tree Graphical User Interface

Figure 1. EA Tree Graphical User Interface


In the next few section, we will go over the basic concepts of EA Tree.

1. Basic Concepts

The concept of the "box" and "buttons".

Boxes are a representation of information in EA Tree. They may contain technical indicator, mathematical function, etc. Each box has input buttons and output buttons. In this example, the Add box has three input buttons labeled A, B, and С and one output button labeled OUT.

Each box has a unique label using its name followed by an index. In this example the label Add_1 indicates that the box name is Add and its index is 1, which means that it was the first box that was created in a layout of boxes.

Figure 2. Add box

Figure 2. Add box

Connecting buttons:

Output buttons of one box can be connected to input buttons of another box if they have the same data types, e.g. they are both double data type.

In this example, we connect the OUT button of the Add_2 box to the A button of the If_Else_1 box.

Figure 3. "Add" box + "if else" box

Figure 3. "Add" box + "If-Else" box

2. The "Trade" box

The Trade box is the main box in EA Tree. It has many input buttons. The most important buttons are the openLong, openShort, closeLong, and closeShort buttons. There are also many trading parameters.

 Figure 4. "Trade" box

Figure 4. "Trade" box

3. The "MM" (MoneyManagement) box

The MM box handles MoneyManagement in EA Tree. It has several input buttons. You need to connect its output button to the MM button of the Trade box.

Figure 5. "Trade" box + MM box

Figure 5. "Trade" box + MM box


4. Logic Boxes

Logic boxes are important to connect between trade box condition buttons: openLong, openShort, closeLong, and closeShort and the rest of the boxes in the layout.

If-Else logic box

The If-Else box has this logic:

If A operator B then T(output button) is true else F(output button) is true.

Where operator could be equal to, not equal to, less than, greater than, etc.

Figure 6. "If-Else" logic box

Figure 6. "If-Else" logic box

Crossover logic box

The Crossover box has this logic:

If A operator1 B AND C operator2 D then T(output button) is true else F(output button) is true.

Where operator1 and operator2 could be equal to, not equal to, less than, greater than, etc. The shifts sets indexes of the indicators to connect to.

In this example we have this logic:

If current Stochastic main > current Stochastic signal and

If previous Stochastic main > previous Stochastic signal

Then T is true and F is false

Figure 7. Crossover + Stochastic Logic boxes

Figure 7. "Crossover" + "Stochastic" logic boxes

AND logic box

The AND box has this logic:

If (A AND B AND C AND D) then OUT(output button) is true

Figure 8. "And" box

OR logic box

The OR box has this logic:

If (A OR B OR C OR D) then OUT (output button) is true

Figure 9. "Or" box

Figure 9. "Or" box


5. Technical Indicators Boxes

There are many technical indicators listed under the Technical Indicators menu such as the MACD and Moving Average (MA) technical indicator boxes

The MACD technical indicator box

Figure 10. MACD technical indicator box

Figure 10. MACD technical indicator box

The MA (Moving Average) technical indicator box

Figure 11. MA (Moving Average) technical indicator box

Figure 11. MA (Moving Average) technical indicator box

6. Custom Indicators

Custom Indicators tools are available at the Custom Indicators Menu and the Toolbar. EA Tree uses only MQL5 custom indicators.

7. MQL5 Functions

EA Tree has many boxes for MQL5 functions including:

  • Time Series Boxes such as iOpen, iClose, HighestHigh, LowestLow, etc.
  • Conversion Functions;
  • Math Functions;
  • String Functions.

8. Tutorial: Creating a simple Expert Advisor

In this section, let us use some of the tools covered in this article to create a simple EA.

First, let us list the Expert Advisor trade rules.

Entry Rules:

Open Long:

  1. Current MACD main > current MACD signal and
  2. Previous MACD main < previous MACD signal and
  3. Current EMA(20) > previous EMA(20)

Open Short:

  1. Current MACD main < current MACD signal and
  2. Previous MACD main > previous MACD signal and
  3. Current EMA(20) < previous EMA(20)

Exit Rules:

Close Long: same rules as Open Short
Close Short: same rules as Open Long

We will use default trade box and no money management settings.

Let us get started:

1. Create a Trade box and create an AND box and connect its output to the openLong button of the Trade box:


Figure 12. Trade box + And Box

Figure 12. Trade box + And Box

2. Create a Crossover box using and connect its T(true) output button to the A button of the And box.

Figure 13. Trade box + And box + Crossover box

Figure 13. Trade box + And box + Crossover box

3. Create a MACD box using, connect its Main output button to the A and C buttons of the Crossover box, and connect its Signal output button to the B and D buttons of the Crossover box.

The logic here is:

If current MACD main > current MACD signal and
      
previous MACD main < previous MACD signal

Figure 14. Trade box + And box + Crossover box + MACD box

Figure 14. Trade box + And box + Crossover box + MACD box


4. Create a MA and If-Else boxes. Connect the Main output button of the MA box to the A and B buttons of the If-Else box. Connect the OUTPUT of IF-Else box to the B button of the AND box.

The subtree for the openLong condition is now complete with these three conditions:

  1. Current MACD main > current MACD signal and
  2. Previous MACD main < previous MACD signal and
  3. Current EMA(20) > previous EMA(20)

Figure 15. Trade box + And box + Crossover box + MACD box + MA box + If-else box

Figure 15. Trade box + And box + Crossover box + MACD box + MA box + If-else box

5. Create another And box and connect its output button to the openShort button of the trade box.

6. Since the openShort logic is the opposite of that of the openLong, connect the F output button of the Crossover box to the A button of the new And box. Also, connect the F output button of the If-Else box to the B button of the new And box:


 Figure 16. Trade box + And box + Crossover box + MACD box + MA box + If-else box + And box

Figure 16. Trade box + And box + Crossover box + MACD box + MA box + If-else box + And box

7. To get exit signals, connect the OUT variable of the first AND box to the closeLong button of the Trade box and the OUT variable of the second AND box to the closeShort button of the Trade box:

 Figure 17. Adding CloseShort to the Trade box
 Figure 17. Adding CloseShort to the Trade box

8. Double click on both MACD and MA boxes and select a number of variables to be input variables in the MQL5 EA that we will generate.

Figure 18. Input parameters

Figure 18. Input parameters

9. The layout is now complete. Save the Layout and save the MQL5 file. Then open the new MQL5 Expert Advisor file in MetaEditor 5 and compile it.

Figure 19. Generated Expert Advisor

Figure 19. Generated Expert Advisor

10. Finally, we optimize selected input variables in MetaTrader 5 Strategy Tester.


Figure 20. Testing of the Expert Advisor 

Figure 20. Testing of the Expert Advisor


Conclusion

There are many benefits of using EA Tree:

  • Easy to use and understand drag and drop graphical user interface;
  • You do not need programming background;
  • You can quickly learn MQL5;
  • Privacy of your trading secrets;
  • You decrease Expert Advisor development time to minutes instead of days or months;
  • You can develop complex MQL5 Expert Advisors with multiple currencies and multiple timeframes;
  • You can incorporate multiple trading strategies into one Expert Advisor;
  • You easily reuse code by saving and loading diagrams (trees of boxes);
  • You are still able to import MQL5 custom indicators;
  • You create correct MetaTrader 5 MQL code every time.
Attached files |
eatree-sample.mq5 (33.7 KB)
Last comments | Go to discussion (41)
Leonardo Ciaccio
Leonardo Ciaccio | 11 Oct 2016 at 21:09
For MT4 use this, without installation for all browser 😜 Watch this video, the best http://j.mp/2dtVd5z
Balut
Balut | 16 Dec 2016 at 12:59
PH2000:
154
Blaiserboy 2014.02.09 20:57  PT
The trailing stop function re MT5 has to be revised as it is not called

 

 Dear

Dave,

First I owe you an apology for asking.

I´m having some problems with my EA since a start this program. To fit the boxes was so easy(demo version) but my standard version Eatree EAs aren´t running in my mt5 broker.

I don´t work with forex and so five digits too.(only two digits). I´m having "divided by zero" problems and i think it is because off different types parameters off trailing step and lot size

As you see i´m not a C++ or MT5 programmer but a I saw most off .mt5 files with lot and stops (double) parameters

With EATree all i could see was integer stops parameters in the "trade 1 box” and double lots parameters to fit it

I´ve  already seen the user guide, demos videos and faq´s and  in despite off there is a lot off box fitting examples there is almost nothing about MM, Lot and stops parameters 

Do i have to convert the integer stops parameters to doubles types one? How can i do it?

Many thanks for considering my request

PH 2000  


Balut
Balut | 16 Dec 2016 at 13:01
I bought EATree mt5
No one EA works with my broker
  I have problems "shared by zero"
I asked the EATree support for explanation
There was no usable answer.
Have you solved the prolem and how?

Greetings Balut
Charles Magno
Charles Magno | 11 Dec 2018 at 12:24
Are there some functional ea builder? 
Is EATree updated? Is it working on mt5 yet?
rayapureddy
rayapureddy | 16 Feb 2019 at 13:13
i have a problem, that in eatree when i make file and save it, its not coming in meta editor 5 , where it is saving iam not getting, can any one explain clearly from layout saving to mt5 saving ,up to meta editor5.
Interview with Igor Korepin (ATC 2011) Interview with Igor Korepin (ATC 2011)
Appearance of the Expert Advisor cs2011 by Igor Korepin (Xupypr) at the very top of the Automated Trading Championship 2011 was really impressive - its balance was almost twice that of the EA featured on the second place. However, despite such a sound breakaway, the Expert Advisor could not stay long on the first line. Igor frankly said that he relied much on a lucky start of his trading robot in the competition. We'll see if luck helps this simple EA to take the lead in the ATC 2011 race again.
Interview with Tim Fass (ATC 2011) Interview with Tim Fass (ATC 2011)
A student from Germany Tim Fass (Tim) is participating in the Automated Trading Championship for the first time. Nevertheless, his Expert Advisor The_Wild_13 already got featured at the very top of the Championship rating and seems to be holding his position in the top ten. Tim told us about his Expert Advisor, his faith in the success of simple strategies and his wildest dreams.
Interview with Ilnur Khasanov (ATC 2011) Interview with Ilnur Khasanov (ATC 2011)
The Expert Advisor of Ilnur Khasanov (aharata) is holding its place in our TOP-10 chart of the Automated Trading Championship 2011 participants from the third week already, though Ilnur's acquaintance with Forex has started only a year ago. The idea that forms the basis of the Expert Advisor is simple but the trading robot contains self-optimization elements. Perhaps, that is the key to its survival? Besides, the author had to change the Expert Advisor planned to be submitted for the Championship...
ATC Champions League: Interview with Olexandr Topchylo (ATC 2011) ATC Champions League: Interview with Olexandr Topchylo (ATC 2011)
Interview with Olexandr Topchylo (Better) is the second publication within the "ATC Champions League" project. Having won the Automated Trading Championship 2007, this professional trader caught the attention of investors. Olexandr says that his first place in the ATC 2007 is one of the major events of his trading experience. However, later on this popularity helped him discover the biggest disappointment - it is so easy to lose investors after the first drawdown on an investor account.