MetaQuotes Language (MQL) is a programming language used exclusively with MetaTrader Software to create automated trading robots and financial market indicators. MQL is a “full access language,” which simply means that MQL lets you create, update, delete, and query most of the data domains in the EMdF model – databases, objects, object types and features. MQL, as it is known and used today, was released on July 1, 2005 along with MetaTrader 4 (MT4). The new language was called MQL4. The platform and integrated programming language were a hit and rapidly became the de facto standard-bearing trading platform within the forex trading marketplace.MQL5 was later released in 2010 as an attempt to branch out into forex.
While you may get several MQL programming tutorials on the net, not all of them will actually introduce the concept properly. This article aims to highlight certain aspects of MQL that will be beneficial for novice traders.
- Basic terms
The MQL language is derived from C++. So if one has sound knowledge of C++ then learning MQL is no issue, even without any prior experience. Some of the basic terms you have to note are:
- Control: Control refers to the part of the program that is being executed. In other words, it refers to the part of the code that the Terminal reads and performs.
- Execution: Execution in this context, refers to implementing the algorithm. The terminal reads the code of the program and executes accordingly.
- Tick: Tick refers to the new inbound price. Programs are executed by new ticks.
- Comment: Comment refers to the part of the program yet to be executed. It is characterised by two consecutive slashes.
- Terminal: Terminal is the classic user interface of Meta Trader, where MQL codes are executed.
- Compilation: The last phase of the creation of the program is called compilation.
- MQL IDE
You can write MQL in a plain text editor, but it must be compiled within MetaTrader. Both the client version of MT4 and MT5 provide an integrated development environment or IDE known as MetaEditor. It allows you to write MQL in the simplest way possible. Within your installed MetaTrader, you can write MQL scripts and execute them using a free demo account trading in fictional currency. You will have to sign up for a trading account if you want to deploy the scripts for live trading.
- MQL4 and MQL5
There are two versions of the MQL language: MQL4 and MQL5. MQL4 is used to write the code for Expert Advisors, indicators, scripts, and MT4 function libraries in MetaTrader 4. MQL5 is an upgraded analogue of MQL4 to use in the MetaTrader 5 platform. There are no consensus among traders and analysts regarding which is the better language, as some say they are quite similar while other believe they are different. There are several indicators that are MTQ4 written but can run in MT5 without any problems. When it comes to educational tools and general awareness regarding the two languages, MQL4 is far more popular than MQL5. While many brokers offer both MetaTrader 4 and 5, the preference is still towards MQL4.
Conclusion
Before diving into coding and writing programs yourself, you have to completely know the in and puts of the programming language you’re using. Slight mistakes and miscalculations can lead to substantial financial losses if executed. The primary sources of educational resources for aspiring MQL tutorials are the official MQL4 and MQL5 documentation websites. Since MQL4 and MQL5 scripts can only be executed within the corresponding version of MetaTrader, beginning programmers should take care to learn the language that is applicable to the version of MetaTrader that is offered by their broker.