Download MetaTrader 5

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

1 November 2011, 12:29
eatree
36
9 808

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 (36)
eatreeMT5
eatreeMT5 | 12 Dec 2013 at 18:37

With new EATree MT4 build 12, you can create "indicator of indicator". For example, Stochastic of RSI, or Momentum of RSI.

 www.eatree.com

 

 indicator of indicator in EATree MT4 build 12

david mackay
david mackay | 9 Feb 2014 at 20:57
The trailing stop function re MT5 has to be revised as it is not called
PH2000
PH2000 | 30 May 2014 at 03:39
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  


Karol Mileszko
Karol Mileszko | 7 Jun 2016 at 06:56
eatreeMT5:

With new EATree MT4 build 12, you can create "indicator of indicator". For example, Stochastic of RSI, or Momentum of RSI.

 www.eatree.com

 

 

Is the "indicator of indicator" functionality available on the demo version? I wanted to try making MA of OBV but can't find DoubleToInt under Function->Conversion in MQL5 version. Besides, how do you correctly connect the nodes? I asked the EATree support for explanation but apart from having received a screen shot without a word of explanation I never got a proper reply (not great for something supposedly available for people without programming background).
elettroelettro
elettroelettro | 7 Jul 2016 at 14:44
Goodmorning everyone
I tried the software and I have to congratulate the authors for the great work done.
Unfortunately I am not a programmer and I have a hard time creating my expert advisor.
I found a few examples on the net that help me to learn how to use EA Tree.
For example, I tried to create a simple expert him to open an order at a certain time of the day but was not able to put together the blocks.
Probably each block signals are to be converted and adapt but I do not have enough knowledge to do this and the few tutorials I've found are not sufficient to learn.
can you help me?
thank you
Step on New Rails: Custom Indicators in MQL5 Step on New Rails: Custom Indicators in MQL5

I will not list all of the new possibilities and features of the new terminal and language. They are numerous, and some novelties are worth the discussion in a separate article. Also there is no code here, written with object-oriented programming, it is a too serous topic to be simply mentioned in a context as additional advantages for developers. In this article we will consider the indicators, their structure, drawing, types and their programming details, as compared to MQL4. I hope that this article will be useful both for beginners and experienced developers, maybe some of them will find something new.

Here Comes the New MetaTrader 5 and MQL5 Here Comes the New MetaTrader 5 and MQL5

This is just a brief review of MetaTrader 5. I can't describe all the system's new features for such a short time period - the testing started on 2009.09.09. This is a symbolical date, and I am sure it will be a lucky number. A few days have passed since I got the beta version of the MetaTrader 5 terminal and MQL5. I haven't managed to try all its features, but I am already impressed.

False trigger protection for Trading Robot False trigger protection for Trading Robot

Profitability of trading systems is defined not only by logic and precision of analyzing the financial instrument dynamics, but also by the quality of the performance algorithm of this logic. False trigger is typical for low quality performance of the main logic of a trading robot. Ways of solving the specified problem are considered in this article.

Using text files for storing input parameters of Expert Advisors, indicators and scripts Using text files for storing input parameters of Expert Advisors, indicators and scripts

The article describes the application of text files for storing dynamic objects, arrays and other variables used as properties of Expert Advisors, indicators and scripts. The files serve as a convenient addition to the functionality of standard tools offered by MQL languages.