Expert Advisor Design E-mail

 

To design your expert advisor for MetaTrader 5 you need to create a trading diagram that represents your EA logic. It's really simple. Just add icons, then connect them and set their configuration parameters.

 

Expert Advisor Visual Wizard Icons (Trading Blocks)

 

start blockSTART

The START icon has two main functions: Indicates where the forex strategy starts and allows the Expert Advisor setup. To access the setup options simply double click on the START trading block and you will be prompted with the following screen:

 

Expert Advisor Setup

 

When the Expert Advisor code is generated, the options on the START trading block are transformed into MQL5 variables. This means that each variable in the START trading block has an equivalent variable on MetaTrader 5.

 

technical analysis trading block TA

The TA  - Technical Analysis icon allows you to create trading conditions using technical indicators and price related variables (Open, Close, High, Low, Ask, Bid, User Defined).

Trading Conditions: A trading condition is the logic that indicates when to trade (Buy or Sell) i.e. Buy if the fast moving average is higher than the slow moving average. Simple conditions include a TA (Technical Analysis) icon that connects to a BUY or SELL icon. If the condition in the TA icon is true, a trade will be executed. Complex trading conditions include a combination of TA icons using an OR icon or an AND icon. When an AND icon is used, trades are executed if all trading conditions in the TA icons that connect to the AND are true. When an OR icon is used, trades are executed if any of the trading conditions in the TA icons that connect to the OR is true.

 

To create a trading condition, edit the Technical Analysis trading block (TA), select a technical indicator from the list on the left. Then set up the indicator parameters. Repeat the same procedure from the list on the right. Finally select one of the comparison options and click OK.

 

Expert Advisor condition

 

Using Custom Indicators in a trading condition: TA icons include all the technical indicators available in a MetaTrader 5 installation. However external indicators can be used to create trading conditions. In a TA block, select Custom Indicators - iCustom and input the appropriate variables or use the import custom indicator button. Custom indicators must be located in the indicators directory (C:\Program Files\MetaTrader 5\MQL5\Indicators for standard installations of MT5)

 

custom indicator mql5

 

Select indicator mql5

 

Custom Indicator fields


What is mode and shift?
The mode and shift concepts are widely used to get the right signals from indicators.

Mode: It's an index used to identify one of the available indicator signals. i.e. If you have 8 lines in your graph, each one gives you a signal. With mode you select the line that gives you the right signal. Most of the time indicators have one line so 0 should be used. 

Shift: Shift relative to the current bar the given amount of periods ago. If you want the value of the indicator for the previous bar you use a shift of 1. To obtain the indicator value for the current bar, 0 should be used.

 

and trading block AND

Produces a value of true if and only if both of its preceding trading blocks are true.

 

or trading block OR

Produces a value of true whenever one or more of its preceding trading blocks are true.

 

buy trading block BUY

Executes a Buy Order. Options in this trading block inlcude Currency Pair, Lot Size, and the pip value for Take Profit, Stop Loss, and Trailing Stop.

 

Buy option EA

 

sell trading block SELL

Executes a Sell Order. Options in this trading block inlcude Currency Pair, Lot Size, and the pip value for Take Profit, Stop Loss, and Trailing Stop.

 

close long trading block CLOSE LONG

Closes all long positions for the selected currency pair.

 

Close position in EA

 

close short trading block CLOSE SHORT

Closes all short positions for the selected currency pair.

 

notes trading blockNOTES

Allows you to write you own notes about the forex strategy. Also called text box.

 

end trading block END

Trading Block that indicates where the strategy finishes. All trading flows must end at the END block.

 

connecting arrowa CONNECTING ARROWS

Connecting arrows link trading blocks and define trading flow direction.

 

Code Generation
Once you have your strategy design go to the Trading Diagram Menu, click on Generate MQL5 Code to get the MQL5 Code window.

 

Generate mql5 EA

 

Expert Advisor Visual Wizard allows you to open your expert advisor directly with MetaTrader or to save it as an MQL5 file.

 

mql5 code for MetaTrader

 

Simple Moving Average Trading Diagram

A simple MA strategy (Buy if fast moving average is higher than the slow moving average and vice-versa) is represented in the following diagram:

 

Moving Average Expert Advisor

 

Moving Average Crossover Trading Diagram

An MA crossover strategy is represented in the following diagram:

 

MA Crossover

 

Price Action Multi-Currency Trading Diagram

You can create trading diagrams that generate multi-time frame, multi-currency EAs

 

Expert Advisor OR example

 

To fully understand how to create trading diagrams, please review our examples or look at this video of our builder for MT4

 

 

Quick Links