Creating and compiling Expert Advisors

In Alphadvisor’s Builder Expert Advisors can be constructed by means of a very intuitive visual editor, requiring no programming knowledge. Robots are built by dragging blocks, which implement different functionalities, into a design canvas, and connecting them to define their execution order. On the right-side third of the screen the help on the different blocks can be consulted, and their parameters can be tweaked, as well. Once the robot is fully designed it must be compiled in order to backtest and trade it.

Defining expressions in function-value windows

Certain blocks (such as, for instance, Technical Analysis) contain parameters which must be introduced by means of function-value windows. In these windows we can build complex expressions by combining values of different nature (OHLC candles, indicators, variables, constants,…) by means of arithmetic operators. In addition, every auxiliary variable employed in the calculations can be exported, so its value can be modified from MetaTrader4.

Exported and global variables

Exported variables, as well as global variables, can be defined from within the Builder, by right-clicking on the corresponding section. The values of both kinds of variables can be modified from MetaTrader4, being the main difference that global variables keep their value after MetaTrader4 has been closed, whereas exported variables do not.

Expert Advisor building blocks

Start blocks

Start blocks are necessary as the first blocks of every execution flow composing our Expert Advisors. There are two types of these blocks, depending on our desire to run the flow at the opening of every new candle or when a new tick is received by the broker.

Analyze blocks

Analyze blocks are used to divide the execution flow depending on the meeting of certain conditions. The most common of them is the Technical Analysis block, in which the results of two expressions built in function-value windows are compared. If the required condition is met, the flow continues towards the block connected to the Y corner of the analysis. If, on the contrary, it is not met, it continues through the N connector.

Technical Analysis Multiple blocks allow to define several nested Technical Analysis conditions in just one block. So, the AND option will continue the execution through the S connector only if every defined condition is met, whereas the OR option will do if at least one of those conditions is met.

Apart from these generic blocks, a number of additional blocks, performing more specific analysis, are included in the Analysis section. What they do can perfectly be replicated employing Technical Analysis blocks, but they are easier to use.

Open blocks

As it can easily be deduced from their name, open blocks are to be used when we want to open trades, either buy trades or sell trades, market trades or limit trades. Concerning limit orders, it is important to define their expiration as a positive number or they will not work properly.

In addition, we can configure different options for the trades to be defined, such as their names, Stop Losses and Take Profits (either fixed, in pips, or dependent of a function-value expression in their Indicator variants), and the money management to apply. Apart from that, a security parameter named Margin Percent is available, as well. This avoids to open trades if the equity percentage remaining as free margin is less than the value we want.

Close blocks

Equivalent to open blocks, close blocks allow to close trades. One can close a particular trade, identified by name, or a group of trades depending of their type and current situation.

Order management blocks

Order management blocks are useful to modify the parameters of a previously defined trade. In this regard, the order must be identified by name. The available options are: to establish a trailing stop (a Stop Loss which grows as the trade earns pips), a break-even (to avoid losing pips after a certain number of pips has already been earnt), or the more generic ones which define movable limit orders, Take Profits or Stop Losses depending on a function-value expression.

Mql blocks

In this section there are options to save values in previously defined exported or global variables. In addition, there is a block especially designed for power users who know how to program in MQL4. This blocks allows to write a chunk of MQL4 code freely and incrust it wherein we set the block.

Order information blocks

Order information blocks divide the execution flow depending on the properties of the trades currently defined. The block names are self-explanatory and the particular functionality of them can be deduced thereof.

Filter blocks

Filter blocks allow to divide the execution flow depending on the time, the day of the week or month, or the current month, at runtime.

Account blocks

By means of account blocks the execution flow can be divided depending on the balance, equity or free margin of the account wherein the Expert Advisor is trading.

Information blocks

Information blocks send a message at runtime. We can choose to print the message in the MetaTrader4 terminal, to open it as an alert in a pop-up window, or to receive a notification in our MetaTrader4 mobile app.

File extensions

Alphadvisor’s builder saves the flow diagrams in a proprietary file format, with an EA4 extension.

You should find these files in the MQL4\Experts folder of the MetaTrader4 terminal connected to Alphadvisor.

When a flow diagram is compiled, the executable EX4 file is generated. MetaTrader4 only needs this file to run the robot. It will appear in the experts folder with a grey circle.

In the case of having an annual or lifetime Alphadvisor license, the MQL source code of the Expert Advisor is also generated. The robot will appear in the experts folder with a golden circle.

The robots generated under a FREE license are executable (EX4), but their source code is not available (MQ4). Backtest and optimization can be performed on them, but not demo or live trading.