EA Tree MT5 V2.0 MataTrader 5 Expert Advisor Builder User .

Transcription

EA Tree MT5 V2.0MataTrader 5 Expert Advisor BuilderUser Guidehttp://www.eatree.comEA Tree MT5 V2.0 User GuidePage 1

What is the Metatrader 5 platform?MetaTrader 5 is a very powerful trading platform designed to arrange brokerageservices in Forex, CFD, Futures, as well as equity markets around the globe. Thebest part is that the MetaTrader 5 platform, real time data, and the MQL 5 languageare available to you for free.What is EA Tree?EA Tree is a Metatrader 5 drag and drop expert advisor builder. It is a windowsapplication that runs locally on your computer. You can create complex MQL5 EAsusing a very easy to use graphical user interface.There are two different products:-EATree MT4 standard Edition V2.0 that supports the MQL4 languageEATree MT5 standard Edition V2.0 that supports the MQL5 languageThis user guide supports EATree MT5 standard Edition V2.0In EA Tree, expert advisors are created by connecting boxes together. Boxes maycontain MQL functions, technical indicators, custom indicators, or values. Outputs ofone box may be connected to inputs of another box to form a “tree of boxes”. EATree generates MQL code from the “tree of boxes” and then uses the MetaTrader 5platform installed on your computer to convert the MQL code into an executableExpert Advisor.Benefits of using EATree Easy to use and understand drag and drop graphical user interfaceEA Tree MT5 V2.0 User GuidePage 2

You do not need programming backgroundYou can quickly learn MQLPrivacy of your trading secrets. No need to share your ideas withprogrammers.You decrease EA development time to minutes instead of days or months.You can develop complex MQL EAs with multiple currencies and multipletimeframes.You can incorporate multiple trading strategies into one EAYou easily reuse code by saving and loading diagrams (trees of boxes)You are still able to import MQL custom indicatorsYou create correct MetaTrader MQL code every timeContentsQuick Start: Creating a Simple EAEA Tree MT5 V2.0 User GuidePage 3

1. Basic Conceptsa. The concept of the “box”b. Input and output buttonsc. Info Dialog Windowd. Connection between boxese. Box help2. The “trade” boxa. Open Long (Buy)b. Open Short (Sell)c. Close Longd. Close Shorte. Trading parameters3. Logic Boxesa. If-Else logic boxb. Crossover logic boxc. AND logic boxd. OR logic box4. Technical Indicators Boxesa. MACD technical indicator boxb. MA technical indicator box5. Custom IndicatorsImporting MQL custom indicators6. Time Series Boxesa. iOpen, iHigh, etc.b. Highest Open, Highest High, etc.c. Lowest Open, Lowest High, etc.7. Function Boxesa. Conversion Functionsb. Math Functions8. Operator Boxesa. Operators9. Layout managementa. New Layoutb. Open Layoutc. Import Layoutd. Save Layoute. Save Layout As10. MQL EA code generationa. Exporting MQL EA source code fileb. Viewing MQL EA source codeEA Tree MT5 V2.0 User GuidePage 4

Edit Menu: deleting a box11. Tutorial: MACD EA12. Color SchemesQuick Start: Creating a simple EAEA Tree MT5 V2.0 User GuidePage 5

In this simple tutorial, you will create a simple EA layout in EATree then view theMQL code and save it.Buy condition: if MACD main indicator line is larger than its signal at previous barSell condition: if MACD main indicator line is smaller than its signal at previous barClick on the Trade button on the toolbar, then click on the middle area of the newTrade box and move it to the right.Click on the condition (If button) on the toolbar, click on the middle area ofthe new condition (If-Else) box and move it to the top middle of the screen,EA Tree MT5 V2.0 User GuidePage 6

then click on the T output button of the condition box and drag a connection line tothe openLong input button of the trade box making a connection. Also connect the Foutput button of the condition box and drag a connection line to the openShort inputbutton of the trade box making a connection.Go to the Indicators menu and select MACD box, click on the middle area of the newMACD box and move it to the left of the screen, then click on the M1 (Main1) outputbutton of the MACD box and drag a connection line to the A input button of theEA Tree MT5 V2.0 User GuidePage 7

condition box making a connection. Also connect the S1 (Signal1) button of theMACD box and drag a connection line to the A input button of the condition boxmaking a connection.Select File- View MQL5 EA menu item to view the MQL5 code of the EATree layoutyou have just created.Select File- Save as MQL5 EA menu item to Save the MQL5 code of the EATreelayout. The default location directory is "C:\Program Files\MetaTrader 5"You can set the MT5 directory by selecting File- Set Directories menuIn the next few section, we will go over the basic concepts of EATree.1. Basic ConceptsThe concept of the “box” and “buttons”EA Tree MT5 V2.0 User GuidePage 8

Boxes are a representation of information in EATree. They may contain technicalindicator, mathematical function, etc. Each box has input buttons and outputbuttons. In this example, the Add box has three input buttons labeled A, B, and Cand one output button labeled O (Out). Each box has a unique label using its namefollowed by an index. In this example the label Add 4 indicates that the box name isAdd and its index is 4, which means that it was the fourth box created in a layout ofboxes.When you double click on the middle of a box, you will see its info dialog window.For each button of the box the info dialog window lists the following:1. Button label2. Button data type: double, int, string, boolean (bool), etc.EA Tree MT5 V2.0 User GuidePage 9

3. Button value4. New button (variable) name: when generating MQL code, by default, buttonwill have the unique identifier of box label and button label for exampleAdd 4 A refers to a button labeled A in a box labeled Add 4. Setting a Newbutton (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 thisvalue in the MetaTrader platform.Connecting buttons:Output buttons of one box can be connected to input buttons of another box if theyhave 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 buttonof the Condition 6 box, click on the O button and drag a rubber-band line, andrelease it on top of the A button.Please note that buttons have different colors depending on their data types. In theabove example double data types are yellow, bool data types (True) are blue, booldata types (False) are red.Box helpWhen dragging your cursor on top of a box, you will view help info such as boxname, or what it does.EA Tree MT5 V2.0 User GuideP a g e 10

Visible and Hidden buttons:Boxes input button are sometimes hidden to save desk layout space. To show inputbuttons, simply do right-click on the middle of the box and select “show all inputbuttons”. Please note that if one of the input buttons is connected, you will not beable 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.2. The “trade” boxThe trade box is the main box in EATree. It has many input buttons and no outputbutton. Please note that any box code will not be generated unless connected to alayout that includes a Trade box.EA Tree MT5 V2.0 User GuideP a g e 11

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 asextern (input) variables.Trade box input buttons:The followings are trade box input buttons names, data types, and description of what itdoes. If you do not set their values in EATree, you will have another chance in MetaTrader5. However, it would be best if you set all the values that you know in EATree so you do nothave to set them again in MetaTrader 5 every time you modify your EATree layout andcreate a new MT5 EA.EA Tree MT5 V2.0 User GuideP a g e 12

openLong: Open long (Buy) condition, bool type, default is false. Connect it toopen long condition subtree.openShort: Open short (Sell) condition, , bool type, default is false. Connect it toopen short condition subtree.closeLong: Close long condition, bool type, default is false. Connect it to close longcondition subtree.closeShort: Close Short condition, default is false. Connect it to close shortcondition 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 falseif 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 areseparated 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 toa MoneyMgm box.MM: Money Management (MM), default is false, will be activated if connected to aMoneyMgm box.useTime: use a specific trade time in 3 time zonesweekDay: use specific trading days.UseEveryHour: Turn it on if you want the EA to check for entries every hour onlysaving testing time.alerts: If set to true will send alerts to notify you if Open Long or Open Shortconditions are true.emails: If set to true will send emails to notify you if Open Long or Open Shortconditions are true, you need to set your email address in Metatrader 5 platformunder 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 15marginCutOff: double type, Margincutoff, default is 0, Expert Advisor will stoptrading if equity level decreases to that level.3. Logic BoxesLogic boxes are important to connect between trade box condition buttons:openLong, openShort, closeLong, and closeShort and the rest of the boxes in thelayout. All logic boxes are under the Logic Menu.Condition (If-Else) logic boxEA Tree MT5 V2.0 User GuideP a g e 13

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 S1then T is true else (otherwise) F is true.Please note that the “shift” input button value of the Stochastic box is 1, indicatingprevious bar:EA Tree MT5 V2.0 User GuideP a g e 14

Crossover logic boxEA Tree MT5 V2.0 User GuideP a g e 15

The Crossover box has this logic:If A operator1 B AND C operator2 D then T (output button) is true else F (outputbutton) is true.Where operator1 and operator2 could be equal to, not equal to, less than, greaterthan, etc.In this example we have this logic:If Stochastic main M1 in previous bar Stochastic signal S1 in previous barandIf Stochastic main two bars ago M2 Stochastic signal two bars ago S2Then T is trueOtherwise (else) is truePlease note that the “shift” input button value of the Stochastic box is 1, indicatingprevious bar. So M1 and S1 output buttons refer to values at previous bar and M2and S2 output buttons refer to Main and signal values two bars ago.AND logic boxesEA Tree MT5 V2.0 User GuideP a g e 16

The AND box has this logic:If (A AND B AND C AND D) then O (output button) is trueThere are two AND boxes ANDL or ANDLong and ANDS or ANDShort. The two boxeshave that same exact logic, only different colors.The following example shows that the ANDL box is used to connect the Long or Buycondition to the openLong input button of the Trade box. While the ANDS box isused to connect the Short or Sell condition to the openShort input button of theTrade box.How do we get a buy signal?EA Tree MT5 V2.0 User GuideP a g e 17

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 trueA 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 forANDL 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.OR logic boxEA Tree MT5 V2.0 User GuideP a g e 18

The OR box has this logic:If (A OR B OR C OR D) then OUT (output button) is trueThere are two OR boxes OrL or OrLong and OrS or OrShort. The two boxes havethat same exact logic, only different colors.The following example shows that the OrL box is used to connect the Long or Buycondition to the openLong input button of the Trade box. While the OrS box is usedto connect the Short or Sell condition to the openShort input button of the Tradebox.How do we get a buy signal?EA Tree MT5 V2.0 User GuideP a g e 19

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 trueA 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 tobe true in order for ANDL 6 O, the output of the ANDL 6 box to be true andtherefore we get openLong (buy signal).We use opposite logic for openShort (Sell signal) as shown in the red lines.4. Technical Indicators BoxesEA Tree MT5 V2.0 User GuideP a g e 20

There are many technical indicators listed under the Indicators menu such as theMACD and MA (Moving average) technical indicator boxesThe MACD technical indicator boxThe MA (Moving Average) technical indicator boxVisible and Hidden buttons:As described before, indicator boxes’ input buttons are hidden to save desk layoutspace. To show input buttons, simply do right-click on the middle of the box andselect “show all input buttons”. Please note that if one of the input buttons isconnected, you will not be able to show input buttons until you remove allconnections 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 withexample if shift 1, then M1 is thelabels ending with “2” refer to theexample if shift 1, then M2 is thebars ago.“1” refer to the index at the shift input button. ForMain indicator line at previous bar. Output buttonsindex at the shift input button plus one. ForMain indicator line at shift of 1 1 2 which is two5. Custom IndicatorsEA Tree MT5 V2.0 User GuideP a g e 21

Please note that you can only use MT5 custom indicators source file “.mq5” usingCustom 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 namediCustom. The actual custom indicator name is stored in the Name input variable asshown in the following example.In some cases the custom indicators input buttons may be very long, EATree solvesthis problem by replacing their names by in1, in2, in3, and so on. Then the actualname will be generated in the MQL code. But we still have a compact box size withinput button labels of in1, in2, etc.In the following example, we use these entry signals:EA Tree MT5 V2.0 User GuideP a g e 22

openLong: if iCustom(Momentum) is larger than close of previous barWe use opposite logic for openShort.EA Tree MT5 V2.0 User GuideP a g e 23

6. Time Series BoxesTime Series Boxes such as iOpen, iHigh, iLow, or iClose are under the Time SeriesBoxes MenuThere are also other time series boxes such as HighestHigh (Find the highest high inthe previous n bars), HighestLow, etc.EA Tree MT5 V2.0 User GuideP a g e 24

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 20bars then trigger a buy signalopenShort condition:If low of previous bar is smaller (lower) than the lowest low in the previous 20 barsthen trigger a sell signalEA Tree MT5 V2.0 User GuideP a g e 25

7. Function BoxesThere are several types of function boxes under the Functions Menu: conversionfunctions and math functions.Conversion FunctionsConversion functions are very important because many buttons (variables) havedifferent data types, e.g. double, int, string, etc. buttons of different data typescannot be connected and their data types have to be converted first. Usually you willneed to convert data type to a string data type first then convert it to desired datatype.Math FunctionsThere are many math functions such as Abs, Max, Min, Floor, etc.EA Tree MT5 V2.0 User GuideP a g e 26

8. Operator BoxesUnder the Operators menu, there are Arithmetic Operators such as the Add,Subtract, and Multiply operators.EA Tree MT5 V2.0 User GuideP a g e 27

9. Layout managementLayout is the hierarchy of boxes or tree of boxes. Tools to manage the layout areavailable under the File menu or the left of the toolbar.You can set the EATree and MT5 directories by selecting File- Set Directories menuNew LayoutClear the screen and start a new layoutOpen LayoutClear the screen and open an existing layoutImport LayoutInsert an existing layout. It is very useful when inserting a subtree of boxes that isused often.Save LayoutSave a layout in the EATree Layout “ly5” format. Do not enter the “.ly5” fileextension.Save Layout AsSave 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 errorswhen you compile your EA in MetaEditor.exe.Please also note that the old “lay” file extension for EATree MT5 has been replacedby the new “ly5” file extension.EA Tree MT5 V2.0 User GuideP a g e 28

10. MQL EA code generation and viewingTools to generate MQL code are available under the File menu or the toolbar. Youcan set the EATree and MT5 directories by selecting File- Set Directories menuSelect File- View MQL5 EA menu item to view the MQL5 code of the EATreelayout you have just created.Select File- Save as MQL5 EA menu item to Save the MQL5 code of the EATreelayout. 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 inthe correct folder.Once you saved your MQL5 EA, you need to open the MT5 Meta

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