What Is MQL4 Programming Language?

What is MQL4? MQL4 stands for MetaQuotes Language 4 and is a programming language included in MetaTrader 4. MQL4 is the MQL version 4, the one that works with MetaTrader 4. If you don't know what a programming language is, it means that you have never written code before, which is fine. A programming language is a language that allows a developer, in this case you, to tell the computer to perform specific actions. This sequence of actions then forms a program.

MQL4 was released with the first version of MetaTrader 4 around 2005 and has gone through many updates over the years. An important update was released in 2014, when it was given more power, security, and features, to bring it nearly to the same level as MQL5.

MQL4 and MQL5 have some important differences, but for now we will focus only on MQL4 and MetaTrader 4.

File Extensions

MQL4 files have the following extensions:

  • .mq4 is a source file. It is basically a text file format that contains all the instructions to be executed. You can open them with MetaEditor or any text file editor. This file must be compiled first to run in MetaTrader.
  • .ex4 is a compiled version, an actual program that can be run by MetaTrader. You cannot open it with any other program other than MetaTrader. If you buy a paid indicator or expert advisor, you will probably receive the software with the .ex4 extension.
  • .mqh are libraries, which are files containing additional functions that you can include and use in your programs. Like the .mq4 files, you can open them with MetaEditor or any text editor software.
MetaTrader 4 Files with .ex4 and .mq4 Extensions


A List of .mqh Files with MQL4 Functions


MQL4 uses a syntax similar to C++/C#/C/Java. So, if you already know some of these languages, it will not take long to learn how to use MQL4.

What Can You Really Do with MQL4?

MQL4 is an extremely powerful tool that if used properly can expand you trading possibilities. To give you some examples, with MQL4 you can:

  • Perform mathematical operations like, for example, calculate a position size given risk parameters.
  • Calculate stop-loss and take-profit levels.
  • Open and close orders.
  • Send notifications on to the screen or to an email address.
  • Create log files and reports.
  • Create custom indicators.
  • Automate your trading, letting your computer trade for you without your interaction.

As you can see, MQL4 gives you great powers — learning this language will allow you to benefit from all of them.

MQL programs can be divided into three main categories:

  • scripts
  • indicators
  • expert advisors
MetaEditor Navigator of MQL4 Folder


You can learn more about the these categories from our guide on differences between scripts, indicators, and expert advisors.

Have you already installed MetaTrader 4? If not, please read How to Install MetaTrader 4 Client Terminal.


If you want to get news of the most recent updates to our guides or anything else related to Forex trading, you can subscribe to our monthly newsletter.

© 2005–2021

EarnForex.com

Design — Mart Studio

Forex trading bears intrinsic risks of loss. You must understand that Forex trading, while potentially profitable, can make you lose your money. Never trade with the money that you cannot afford to lose! Trading with leverage can wipe your account even faster.

CFDs are leveraged products and as such loses may be more than the initial invested capital. Trading in CFDs carry a high level of risk thus may not be appropriate for all investors.