Advertisements
$ £ ¥
¥ £ $

What Is MetaEditor for MetaTrader 4?

If you are looking to modify or create new MQL4 code, you need to be familiar with MetaEditor. It is the most important tool for MQL4 coders and is indispensable even if you want to make a small change to some source code. To better understand this guide, you must already know what MQL4 is and what MetaTrader is — these are the starting concepts.

Latest version of MetaEditor 4 at the time of writing
Latest version at the time of writing

If you already have some experience with MetaTrader, the most popular trading platform, you have probably also heard about MQL4, the powerful scripting language that will improve your trading capabilities. For all the traders interested in coding with MQL4, the third main tool to know is MetaEditor. The word MetaEditor sounds similar to MetaTrader, but it focuses on Editor. Basically, MetaEditor is a dedicated Editor to develop, manage, and compile MQL4 programs. MQL4 is a scripting language and the source files are text files with extension MQ4 and MQH. Being text files, they can be opened with any text editor, for example Notepad++ or Wordpad. So why do we need MetaEditor? MetaEditor facilitates the tasks of creating and editing such files in the following ways:

  • Present the code in a well formatted and colored form, which is very easy to read.
  • Navigator panel to browse the files.
  • Option to insert coding elements like variables and functions.
  • Autocompletion to predict and suggest the word that is being typed.
  • Error highlighting.

One of the main functions of MetaEditor is the ability to compile the source files. This needs to be explained as not everyone has a clear idea what does it mean to compile a program. As you know, a computer is a very complex calculator, it perform mathematical operations in a binary system. The code that you write may make sense to you, but as it is in a source file, it does not make sense for a computer to run. This is because it needs to be compiled first!

Compilation is the task that takes a text source file, in this case with a MQ4 extension, and transforms it into an executable file, in this case with a EX4 extension. It can now be executed by a computer or another software. So, in other words, after you have created your source MQ4 file, you need to compile it to produce an executable EX4 file. Compiled files can be only run and not read, so you cannot retrieve the source code they have been created from.

MetaEditor is included in the installation of MetaTrader and is also kept updated by the same process that updates your MetaTrader. To open MetaEditor, you have four options:

  • Option 1 - In MetaTrader, click the menu Tools and then click the MetaQuotes Language Editor option. Running MetaEditor from MetaTrader 4 via Menu
  • Option 2 - While in MetaTrader, press F4 button on your keyboard.
  • Option 3 - In the Standard toolbar, click the MetaEditor icon. Running MetaEditor from MetaTrader 4 via Toolbar
  • Option 4 - In the Windows Start Menu open the MetaTrader 4 group and select MetaEditor. Running MetaEditor from MetaTrader 4 via Windows Start Menu

Once you open MetaEditor, the interface is quite intuitive. You can browse the files in the Navigator, save, open, compile, and run from the menu and toolbars, and check for errors, logs, articles, and additional code in the Toolbox. You will get familiar with it quickly.

MetaEdtior 4 Interface

Now you should have a basic understanding of the tools required to automate your trading:

  • MetaTrader — to trade and run your code.
  • MQL4 — the scripting language.
  • MetaEditor — to create, edit, and compile your code.

You should be ready to start learning how to code at this point.