+ All Categories
Home > Documents > EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor...

EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor...

Date post: 22-Mar-2018
Category:
Upload: hakien
View: 296 times
Download: 17 times
Share this document with a friend
41
EA Tree MT5 V2.0 User Guide | 1 Page EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder User Guide http://www.eatree.com
Transcript
Page 1: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 1 P a g e

EA Tree MT5 V2.0

MataTrader 5 Expert Advisor Builder

User Guide

http://www.eatree.com

Page 2: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 2 P a g e

What is the Metatrader 5 platform?

MetaTrader 5 is a very powerful trading platform designed to arrange brokerage

services in Forex, CFD, Futures, as well as equity markets around the globe. The

best part is that the MetaTrader 5 platform, real time data, and the MQL 5 language

are available to you for free.

What is EA Tree?

EA Tree is a Metatrader 5 drag and drop expert advisor builder. It is a windows

application that runs locally on your computer. You can create complex MQL5 EAs

using a very easy to use graphical user interface.

There are two different products:

- EATree MT4 standard Edition V2.0 that supports the MQL4 language

- EATree MT5 standard Edition V2.0 that supports the MQL5 language

This user guide supports EATree MT5 standard Edition V2.0

In EA Tree, expert advisors are created by connecting boxes together. Boxes may contain MQL 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 MQL code from the “tree of boxes” and then uses the MetaTrader 5 platform installed on your computer to convert the MQL code into an executable Expert Advisor.

Copyright 2010-2012, GGI

Disclaimer: For testing and evaluation purposes only. In no event will authors be liable for any damages whatsoever.

Page 3: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 3 P a g e

Benefits of using EATree

Easy to use and understand drag and drop graphical user interface

You do not need programming background

You can quickly learn MQL

Privacy of your trading secrets. No need to share your ideas with

programmers.

You decrease EA development time to minutes instead of days or months.

You can develop complex MQL EAs with multiple currencies and multiple

timeframes.

You can incorporate multiple trading strategies into one EA

You easily reuse code by saving and loading diagrams (trees of boxes)

You are still able to import MQL custom indicators

You create correct MetaTrader MQL code every time

Page 4: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 4 P a g e

Contents

Quick Start: Creating a Simple EA

1. Basic Concepts

a. The concept of the “box”

b. Input and output buttons

c. Info Dialog Window

d. Connection between boxes

e. Box help

2. The “trade” box

a. Open Long (Buy)

b. Open Short (Sell)

c. Close Long

d. Close Short

e. Trading parameters

3. Logic Boxes

a. If-Else logic box

b. Crossover logic box

c. AND logic box

d. OR logic box

4. Technical Indicators Boxes

a. MACD technical indicator box

b. MA technical indicator box

5. Custom Indicators

Importing MQL custom indicators

6. Time Series Boxes

a. iOpen, iHigh, etc.

b. Highest Open, Highest High, etc.

c. Lowest Open, Lowest High, etc.

7. Function Boxes

a. Conversion Functions

b. Math Functions

8. Operator Boxes

a. Operators

9. Layout management

a. New Layout

b. Open Layout

c. Import Layout

d. Save Layout

e. Save Layout As

Page 5: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 5 P a g e

10. MQL EA code generation

a. Exporting MQL EA source code file

b. Viewing MQL EA source code

Edit Menu: deleting a box

11. Tutorial: MACD EA

12. Color Schemes

Page 6: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 6 P a g e

Quick Start: Creating a simple EA

In this simple tutorial, you will create a simple EA layout in EATree then view the

MQL code and save it.

Buy condition: if MACD main indicator line is larger than its signal at previous bar

Sell condition: if MACD main indicator line is smaller than its signal at previous bar

Click on the Trade button on the toolbar, then click on the middle area of the new

Trade box and move it to the right.

Page 7: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 7 P a g e

Click on the condition (If button) on the toolbar, click on the middle area of

the new condition (If-Else) box and move it to the top middle of the screen,

then click on the T output button of the condition box and drag a connection line to

the openLong input button of the trade box making a connection. Also connect the F

output button of the condition box and drag a connection line to the openShort input

button of the trade box making a connection.

Page 8: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 8 P a g e

Go to the Indicators menu and select MACD box, click on the middle area of the new

MACD box and move it to the left of the screen, then click on the M1 (Main1) output

button of the MACD box and drag a connection line to the A input button of the

condition box making a connection. Also connect the S1 (Signal1) button of the

MACD box and drag a connection line to the A input button of the condition box

making a connection.

Select File->View MQL5 EA menu item to view the MQL5 code of the EATree layout

you have just created.

Select File->Save as MQL5 EA menu item to Save the MQL5 code of the EATree

layout. The default location directory is "C:\Program Files\MetaTrader 5"

You can set the MT5 directory by selecting File->Set Directories menu

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

Page 9: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 9 P a g e

1. Basic Concepts

The concept of the “box” and “buttons”

Boxes are a representation of information in EATree. 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 C

and one output button labeled O (Out). Each box has a unique label using its name

followed by an index. In this example the label Add_4 indicates that the box name is

Add and its index is 4, which means that it was the fourth box created in a layout of

boxes.

When you double click on the middle of a box, you will see its info dialog window.

Page 10: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 10 P a g e

For each button of the box the info dialog window lists the following:

1. Button label

2. Button data type: double, int, string, boolean (bool), etc.

3. Button value

4. New button (variable) name: when generating MQL code, by default, button

will have the unique identifier of box label and button label for example

Add_4_A refers to a button labeled A in a box labeled Add_4. Setting a New

button (variable) name will override Add_4_A with your text, for example,

lots.

5. “Add to EA input variables”: activating this button will make this button

(variable) listed as EA input variables, which makes it easier to optimize this

value in the MetaTrader platform.

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.

For example, to connect the O(OUT) button of the Add_4 box to the A input button

of the Condition_6 box, click on the O button and drag a rubber-band line, and

release it on top of the A button.

Please note that buttons have different colors depending on their data types. In the

above example double data types are yellow, bool data types (True) are blue, bool

data types (False) are red.

Page 11: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 11 P a g e

Box help

When dragging your cursor on top of a box, you will view help info such as box

name, or what it does.

Visible and Hidden buttons:

Boxes input button are sometimes hidden to save desk layout space. To show input

buttons, simply do right-click on the middle of the box and select “show all input

buttons”. Please note that if one of the input buttons is connected, you will not be

able to show input buttons until you remove all connections to input buttons.

To modify hidden buttons values, double click on the box to show its info dialog box.

Then you can modify the values of all input buttons including hidden ones.

Page 12: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 12 P a g e

2. The “trade” box

The trade box is the main box in EATree. It has many input buttons and no output

button. Please note that any box code will not be generated unless connected to a

layout that includes a Trade box.

To create a Trade box Click on the Trade button on the toolbar or select Trade-

>Trade menu item.

Visible and Hidden buttons:

“Trade” box is an exceptional case. It has a selection of input buttons always visible,

and the rest are hidden. The reason for that it has too many input buttons to show.

By default all input buttons of the trade box will show in the generated MQL5 EA as

extern (input) variables.

Page 13: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 13 P a g e

Trade box input buttons:

The followings are trade box input buttons names, data types, and description of what it

does. If you do not set their values in EATree, you will have another chance in MetaTrader

5. However, it would be best if you set all the values that you know in EATree so you do not

have to set them again in MetaTrader 5 every time you modify your EATree layout and

create a new MT5 EA.

openLong: Open long (Buy) condition, bool type, default is false. Connect it to

open long condition subtree.

openShort: Open short (Sell) condition, , bool type, default is false. Connect it to open short condition subtree. closeLong: Close long condition, bool type, default is false. Connect it to close long condition subtree. closeShort: Close Short condition, default is false. Connect it to close short condition subtree. buyOk: If open long condition is true, is it OK to go ahead and open long position? default is true. Set it to false if you want to open short only, or send alerts or emails. sellOk: If open short condition is true, is it OK to sell? default is true. Set it to false if you want to open long only, or send alerts or emails. symbols: List of symbols that you would like to trade. Make sure that they are

separated by “/”. For example: "EURUSD/GBPUSD/USDCHF/USDJPY/GBPJPY”.

takeProfit: int type, Take Profit value. stopLoss: int type, Stop Loss value. trailingStop: int, Trailing Stop value; lots: double type, lots value, this value will be ignored if MM button is connected to a MoneyMgm box. MM: Money Management (MM), default is false, will be activated if connected to a MoneyMgm box. useTime: use a specific trade time in 3 time zones weekDay: use specific trading days. UseEveryHour: Turn it on if you want the EA to check for entries every hour only saving testing time. alerts: If set to true will send alerts to notify you if Open Long or Open Short conditions are true. emails: If set to true will send emails to notify you if Open Long or Open Short conditions are true, you need to set your email address in Metatrader 5 platform under Tools->Options. isMini: bool type, Is Account Mini?, default is true. tradeSizePer: double type, Trade size percent, default is 10. maxLots: double type, Maximum lots, default is 5 (lots). maxPosSum: double type, Maximum Position Sum, default is 15 (lots) maxPosCount: int type, Maximum position count, default is 12. maxPos: double type, Maximum Position, default is 15 marginCutOff: double type, Margincutoff, default is 0, Expert Advisor will stop trading if equity level decreases to that level.

Page 14: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 14 P a g e

3. 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. All logic boxes are under the Logic Menu.

Condition (If-Else) logic box

The Condition (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.

For example:

If previous Stochastic Main indicator line M1 is larger than its previous Signal line S1

then T is true else (otherwise) F is true.

Page 15: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 15 P a g e

Please note that the “shift” input button value of the Stochastic box is 1, indicating

previous bar:

Page 16: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 16 P a g e

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.

In this example we have this logic:

If Stochastic main M1 in previous bar> Stochastic signal S1 in previous bar

and

If Stochastic main two bars ago M2 < Stochastic signal two bars ago S2

Then T is true

Otherwise (else) is true

Please note that the “shift” input button value of the Stochastic box is 1, indicating

previous bar. So M1 and S1 output buttons refer to values at previous bar and M2

and S2 output buttons refer to Main and signal values two bars ago.

Page 17: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 17 P a g e

AND logic boxes

The AND box has this logic:

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

There are two AND boxes ANDL or ANDLong and ANDS or ANDShort. The two boxes

have that same exact logic, only different colors.

The following example shows that the ANDL box is used to connect the Long or Buy

condition to the openLong input button of the Trade box. While the ANDS box is

used to connect the Short or Sell condition to the openShort input button of the

Trade box.

Page 18: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 18 P a g e

How do we get a buy signal?

In the example below, the C and D input buttons of ANDL_6 box are not connected.

But there default values are true as shown in the info dialog box.

The logic at box ANDL_6 is:

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

A is equal to Crossover_2_T (The T output of the Crossover_2 box)

B is equal to Condition_4_T (The T output of the Condition_4 box)

C is always true (default value, because it is not connected)

D is always true (default value, because it is not connected)

Therefore we need BOTH Crossover_2_T and Condition_4_T to be true in order for

ANDL_6_O, the output of the ANDL_6 box to be true and therefore we get openLong

(buy signal).

We use opposite logic for openShort (Sell signal) as shown in the red lines.

Page 19: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 19 P a g e

OR logic box

The OR box has this logic:

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

There are two OR boxes OrL or OrLong and OrS or OrShort. The two boxes have

that same exact logic, only different colors.

The following example shows that the OrL box is used to connect the Long or Buy

condition to the openLong input button of the Trade box. While the OrS box is used

to connect the Short or Sell condition to the openShort input button of the Trade

box.

Page 20: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 20 P a g e

How do we get a buy signal?

In the example below, the C and D input buttons of OrL_6 box are not connected.

But there default values are false as shown in the info dialog box.

The logic at box OrL_10 is:

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

A is equal to Crossover_2_T (The T output of the Crossover_2 box)

B is equal to Condition_4_T (The T output of the Condition_4 box)

C is always false (default value, because it is not connected)

D is always false (default value, because it is not connected)

Therefore we need only one of the two values: Crossover_2_T and Condition_4_T to

be true in order for ANDL_6_O, the output of the ANDL_6 box to be true and

therefore we get openLong (buy signal).

We use opposite logic for openShort (Sell signal) as shown in the red lines.

Page 21: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 21 P a g e

4. Technical Indicators Boxes

There are many technical indicators listed under the Indicators menu such as the

MACD and MA (Moving average) technical indicator boxes

The MACD technical indicator box

The MA (Moving Average) technical indicator box

Visible and Hidden buttons:

As described before, indicator boxes’ input buttons are hidden to save desk layout

space. To show input buttons, simply do right-click on the middle of the box and

select “show all input buttons”. Please note that if one of the input buttons is

connected, you will not be able to show input buttons until you remove all

connections to input buttons.

To modify hidden buttons values, double click on the box to show its info dialog box.

Then you can modify the values of all input buttons including hidden ones.

Indicator Output Buttons:

Output buttons labels ending with “1” refer to the index at the shift input button. For

example if shift=1, then M1 is the Main indicator line at previous bar. Output buttons

labels ending with “2” refer to the index at the shift input button plus one. For

example if shift=1, then M2 is the Main indicator line at shift of 1+1=2 which is two

bars ago.

Page 22: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 22 P a g e

5. Custom Indicators

Please note that you can only use MT5 custom indicators source file “.mq5” using

Custom Indicators->Import MT5 Custom Indicator menu item.

Simply select your custom indicator source file to create a new iCustom box.

Why box and button names are not showing in iCustom box?

Custom indicator file names could be very long. Therefore the box is named

iCustom. The actual custom indicator name is stored in the Name input variable as

shown in the following example.

In some cases the custom indicators input buttons may be very long, EATree solves

this problem by replacing their names by in1, in2, in3, and so on. Then the actual

name will be generated in the MQL code. But we still have a compact box size with

input button labels of in1, in2, etc.

Page 23: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 23 P a g e

In the following example, we use these entry signals:

openLong: if iCustom(Momentum) is larger than close of previous bar

We use opposite logic for openShort.

Page 24: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 24 P a g e

6. Time Series Boxes

Time Series Boxes such as iOpen, iHigh, iLow, or iClose are under the Time Series

Boxes Menu

There are also other time series boxes such as HighestHigh (Find the highest high in

the previous n bars), HighestLow, etc.

Page 25: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 25 P a g e

In the following example, we use the following logic:

openLong condition:

If high of previous bar is larger (higher) than the highest high in the previous 20

bars then trigger a buy signal

openShort condition:

If low of previous bar is smaller (lower) than the lowest low in the previous 20 bars

then trigger a sell signal

Page 26: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 26 P a g e

7. Function Boxes

There are several types of function boxes under the Functions Menu: conversion

functions and math functions.

Conversion Functions

Conversion functions are very important because many buttons (variables) have

different data types, e.g. double, int, string, etc. buttons of different data types

cannot be connected and their data types have to be converted first. Usually you will

need to convert data type to a string data type first then convert it to desired data

type.

Math Functions

There are many math functions such as Abs, Max, Min, Floor, etc.

Page 27: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 27 P a g e

8. Operator Boxes

Under the Operators menu, there are Arithmetic Operators such as the Add,

Subtract, and Multiply operators.

Page 28: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 28 P a g e

9. Layout management

Layout is the hierarchy of boxes or tree of boxes. Tools to manage the layout are

available under the File menu or the left of the toolbar.

You can set the EATree and MT5 directories by selecting File->Set Directories menu

New Layout

Clear the screen and start a new layout

Open Layout

Clear the screen and open an existing layout

Import Layout

Insert an existing layout. It is very useful when inserting a subtree of boxes that is

used often.

Save Layout

Save a layout in the EATree Layout “ly5” format. Do not enter the “.ly5” file

extension.

Save Layout As

Save a layout in the EATree Layout “ly5” format in a new name. Do not enter the

“.ly5” file extension.

Please note that EATree MT4 uses the format “ly4”. Please avoid opening a file with

“ly4” extension as this will result in an incorrect MT5 EA and you will get errors

when you compile your EA in MetaEditor.exe.

Please also note that the old “lay” file extension for EATree MT5 has been replaced

by the new “ly5” file extension.

Page 29: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 29 P a g e

10. MQL EA code generation and viewing

Tools to generate MQL code are available under the File menu or the toolbar. You

can set the EATree and MT5 directories by selecting File->Set Directories menu

Select File->View MQL5 EA menu item to view the MQL5 code of the EATree

layout you have just created.

Select File->Save as MQL5 EA menu item to Save the MQL5 code of the EATree

layout. Do not add the “.mq5” file extension. The default location directory is

"C:\Program Files\MetaTrader 5" you can change so that your EA will be saved in

the correct folder.

Once you saved your MQL5 EA, you need to open the MT5 MetaEditor, double click

on your EA to open it, then hit “compile” to create executable EA “.ex5” that you can

use in MT5 platform.

Edit Menu:

Under Edit Menu, you can cut, copy, and select all boxes.

To delete a box, simply select it and choose Edit->cut or CtrX

Page 30: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 30 P a g e

11. Tutorials: Creating a sample EA

In this section, let us use some of the tools covered in this user manual to create a

sample EA. First, let us list the EA rules.

Entry Rules:

Open Long:

1. previous MACD main > previous MACD signal and

2. MACD main two bars ago< MACD signal two bars ago and

3. Previous EMA (20) > two bars ago EMA (20)

Open Short:

1. previous MACD main < previous MACD signal and

2. MACD main two bars ago> MACD signal two bars ago and

3. Previous EMA (20) < two bars ago EMA (20)

Exit Rules:

Close Long: same rules as Open Short

Close Short: same rules as Open Long

We will use default trade box

Let us get started:

1. create trade box using Trade->Trade, and move it to the right of the screen

Page 31: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 31 P a g e

2. create an AND box using Logic->AndL and connect its output O to the

openLong button of the Trade box

3. Create a Crossover box using Logic-> Crossover and connect its T (true)

output button to the A button of the AndL box.

Page 32: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 32 P a g e

4. Create a MACD box using Indicators-> MACD, connect:

its Main output button M1 to the A button of the Crossover box,

its Signal output button S1 to the B button of the Crossover box,

its Main output button M2 to the C button of the Crossover box, and

its Signal output button S2 to the D button of the Crossover box.

The logic here is:

If previous MACD main M1> previous MACD signal S1 and

MACD main two bars ago M2< MACD signal two bars ago S2

Page 33: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 33 P a g e

5. Create a MA box using Technical Indicators-> Moving average. Create

Condition box using Logic->Condition. Connect the Main output button of

the MA box M1 to the A button of the Condition box and Main output button

of the MA box M2 to the B button of the Condition box.

6. Connect the O output of condition box to the B button of the AndL box.

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

conditions:

1. previous MACD main > previous MACD signal and

2. MACD main two bars ago< MACD signal two bars ago and

3. Previous EMA (20) > two bars ago EMA (20)

Page 34: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 34 P a g e

4. Create an AndS box using Logic->AndS and connect its output button to

the openShort button of the trade box.

5. 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 AndS

box. Also, connect the F output button of the Condition box to the B

button of the new AndS box.

Page 35: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 35 P a g e

6. To get exit signals, connect the O variable of the AndL box to the

closeShort button of the Trade box and the O variable of the AndS box to

the closeLong button of the Trade box.

7. 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.

Page 36: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 36 P a g e

8. The layout is now complete.

9. Save the Layout using File->Save Layout As.

10. If you are using EATree MT5 standard Edition V2.0

save the MQL5 file using File->Save as MQL5 EA. Then open the new

MQL5 EA file in MetaEditor 5, and compile it.

save the MQL5 file using File->Save as MQL5 EA. Then open the new

MQL5 EA file in MetaEditor 5, and compile it.

Page 37: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 37 P a g e

Finally, we optimize selected input variables in MetaTrader 5 tester using

EURUSD H1 timeframe from Jan. 1, 2011 to Oct. 1, 2011 with no money

management. We have used: TakeProfit = 100, StopLoss = 35, MACDfast =

20, MACDslow = 22, MACDsignal = 7, MAperiod = 20.

Page 38: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 38 P a g e

12. Color Schemes

Under View menu there are several color schemes that are created not just to make

your layout look “pretty”, but also to make it creating EA layouts a much easier

process. You can select your favorite color scheme while you are using EATree:

1. "Avant" Color Scheme

The default color scheme which is used in this user guide so far.

2. "Fizz" Color Scheme

Page 39: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 39 P a g e

3. "He Can" Color Scheme with connection line width of 2

4. "Robo" Color Scheme with connection line width of 2

Page 40: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 40 P a g e

5. "Wheels of Fire" Color Scheme

6. "Details" Color Scheme with connection line width of 2

Page 41: EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder · PDF fileMataTrader 5 Expert Advisor Builder User Guide . ... - EATree MT4 standard Edition V2.0 that supports the MQL4 language

EA Tree MT5 V2.0 User Guide | 41 P a g e

7. "Autumn Leaves" Color Scheme with white background

8. "Tangerine Skies" Color Scheme

We wish you successful trading!

Disclaimer: For testing and evaluation purposes only. In no event will authors be liable for any

damages whatsoever.


Recommended