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)
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:
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.
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.
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)
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.
Produces a value of true if and only if both of its preceding trading blocks are true.
Produces a value of true whenever one or more of its preceding trading blocks are true.
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.
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.
Closes all long positions for the selected currency pair.
Closes all short positions for the selected currency pair.
Allows you to write you own notes about the forex strategy. Also called text box.
Trading Block that indicates where the strategy finishes. All trading flows must end at the END block.
Connecting arrows link trading blocks and define trading flow direction.
Once you have your strategy design go to the Trading Diagram Menu, click on Generate MQL5 Code to get the MQL5 Code window.
Expert Advisor Visual Wizard allows you to open your expert advisor directly with MetaTrader or to save it as an MQL5 file.
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 Crossover Trading Diagram
An MA crossover strategy is represented in the following diagram:
Price Action Multi-Currency Trading Diagram
You can create trading diagrams that generate multi-time frame, multi-currency EAs
To fully understand how to create trading diagrams, please review our examples or look at this video of our builder for MT4