What is an Expert Advisor?
An expert advisor is an automated trading program written in MQL. Expert advisors (commonly abbreviated as EA) can place, modify and close orders according to a trading system algorithm. EA’s generally use indicators to generate trading signals. These indicators can be the ones that come with MetaTrader, or they can be custom indicators.
An indicator is a technical analysis tool that calculates price data to give an interpretation of market activity. An indicator draws lines or objects on the chart. Indicators cannot place, modify or close orders. Examples of indicators include the moving average and stochastics.
A script is a simplified expert advisor that performs a single task, such as placing a pending order or closing all orders on a chart. A few useful scripts are included with MetaTrader.
Files with the
.mq4 extension are source code files. These are the files we edit in MetaEditor. When an
.mq4 file is compiled, an
.ex4 file is produced.
Files with the
.ex4 extension are executable files. These are the files we run in MetaTrader. These files cannot be opened in MetaEditor. If you only have the
.ex4 file for an EA or indicator, the icon next to the file name in MetaTrader’s Navigator window will be grayed out.
Files with the
.mqh extension are include files. These files contain user-created functions that are referenced in an
.mq4 file. During compilation, the compiler “includes” the contents of the
.mqh file in the.ex4 file. We’ll learn more about include files later.
.mqt extension is used for template files. While these files can be opened in MetaTrader, the file type is not associated with the program in Windows. Templates are used to create new files using the Expert Advisor Wizard in MetaEditor.
You can create your own templates if you wish. The MetaTrader documentation will tell you all you need to know about creating templates.
Indicators, expert advisors, libraries and scripts all share the
.mq4 extension. The only way to tell them apart is either by their save location, or by opening the file and examining them. After you gained more experience you should be able to identify the difference between program types just by looking at the source code.
All MetaEditor files are stored inside the experts folder. The
\experts folder is contained in the MetaTrader installation directory, which is in
C:\Program Files\. If your broker is Interbank FX, for example, the MT4 installation folder would be
C:\Program Files\Interbank FX Trader 4\.
\experts folder contains the source code and executable files for the expert advisors. Using the above example, the
\experts folder would be located at
C:\Program Files\Interbank FX Trader4\experts\.
There are numerous folders inside the
\experts folder that contain other types of source code and executable files. Here’s a list of the save locations for all file types:
\experts\indicators- Source code and executable files for your indicators are stored here.
\experts\include- Source code include files with the
.mqhextension are stored here.
\experts\libraries- Function libraries and DLLs are stored here.
\experts\scripts- Source code and executable files for scripts are stored here.
\experts\templates- Templates for source code files are stored here.
There are a few other folders inside the experts folder that you’ll want to be aware of too:
\experts\logs- Activity logs for your expert advisors are stored here. These will be usefulfor debugging your expert advisors.
\experts\presets- Expert advisor settings that are saved or loaded from MetaTrader’sPropertiesdialog are stored here.
\experts\files- Any files used for input or output must be stored here.