Technology introduces us to different types of trading platforms to perform analysis and execute trades more efficiently. Metaquotes Corp. is a leading company that provides platform services to its clients. Programming languages like MQL4 and MQL5 made trading effective by opening a new era for developers and traders.
Knowing these languages will enable opportunities to increase your income from the financial market. It helps traders and developers to create new applications to support trading if you correctly understand using these developing tools.
This article differentiates between the developing tools of the latest two trading platforms, MetaTrader 4 and MetaTrader 5. Completing this article will let you know the MQL, the key differences between MQL4 and MQL5, and how to use them.
What are MQL4 and MQL5?
The Meataquotes Corp. is the founder of the trading platform Metatrader. In 2000 and 2001, they created the first two platforms to trade forex, stocks, futures, and CFDs. Back then, these were not such popular terminals among traders with low capacities.
In early 2002, the next version of the trading terminal, MetaTrader 3, was quite good in functionality and capability and lasted for the next three years. Finally, in 2005, MT4 came with colossal functionality and as a user-friendly platform. So it has become popular among traders. So the latest and most capable platform is MT5, which comes in 2010.
MQL or MetaQuotes language is the MetaTrader trading platform’s programming language to build expert advisors (EAs). You can use MetaQuotes language editor to write your indicators, EAs, and other software or applications by using MQL. You can also use it for debugging and compiling them. Metaquote Corp. supplies this environment along with the terminal to their clients. Moreover, they also provide reference information.
The evolutionary improvement of the trading platform is the result of this programming language, MQL. The MQL allows users to implement any algorithm or trading strategy, and the form will be like a computer program.
There is an extensive community around the language. You can check the strategy, compiling, debugging, indicators, expert advisors, or any other applications with MQL without involving any financial risks. You need to look after the general control. MQL4 and MQL5 are the fourth and fifth versions of the MQL. The foundation date of MQL4 was July 1, 2005, and for MQL 5, it was June 2010. However, another update came in 2014 to introduce the latest features of MQL5.
Key features: MQL4 vs. MQL5
Developers and traders use MQL to create automatic trading strategies, indicators, and so on applications. C++ interpretation is the primary code base for MQL that works inside the trading terminal by writing executable codes. A vast community of traders and developers exchange their knowledge and skills that keep the network going. There are hundreds of paid signals, indicators, and other services that developers offer through the terminal. Developers share hundreds of ideas and tutorials on various topics of trading. That includes new ideas, limitations of coding, testing and analyzing new strategies, implementation, etc.
MQL4 offers eight options, and the latest version, MQL5, offers ten.
Let’s have a look at the standard features among these two:
- Script
- Indicator
- Include files (.mqh) library
- Expert advisors or trading robots
When you complete the compilation or in executable code and save it, it goes to the proper library of the terminal — for example, scripts, experts, etc. You can also create applications by using another programming language, Python.
In MQL5, you can have an increasing number of handlers compared to the previous version, MQL4.
The enhanced list of events in the MQL5 language allows developers to add more conditions to a trading strategy. So, any EAs in the MQL5 language are more effective, profitable, and have better risk management.
Data and syntax of MQL4 and MQL5 languages
MQL syntaxes are similar to the programming language C++. We differentiate these two programing language syntaxes depending on several facts, such as:
- Text format
You can use any space, empty strings, tabs, or several blanks to make your code easier and readable. It will not allow the use of blanks within keywords, identifiers, and constants. You will see restrictions on using line change characters after the hash.
- Comments
You can have single-line or multiple-line comments in MQL4/MQL5. A single-line comment begins with a // and ends with a newline character. Meanwhile, a multi-line comment starts with /* and finishes with */.
- Identifiers
The length of an identifier will not be more than 63 characters. You can use uppercase, lowercase letters, numbers between 0-9, underscores (_), and other characters. This language won’t allow you to use zero as the first character.
Difference between MQL4 and MQL5 codes
You can identify the differences between these two latest trading platforms languages for MT4 and MT5. The fifth and latest version has more functions and moods in comparison to the fourth.
MQL4 | MQL5 | |
Time frames | 9 (M1, M5, M15, M30, H1, H4, D, W, MN) | 21 (M1, M2, M3, M4, M5, M6, M10, M12, M15, M20, M30, H1, H2, H3, H4, H6, H8, H12, D1, W1, MN1) |
Drawing styles | 6 DRAW_NONE DRAW_LINE DRAW_SECTION DRAW_HISTOGRAM DRAW_ARROW DRAW_ZIGZAG With build 600, the number has become consistent with the fifth version | 18 DRAW_NONE DRAW_LINE DRAW_SECTION DRAW_HISTOGRAM DRAW_HISTOGRAM2 DRAW_ARROW DRAW_ZIGZAG DRAW_FILLING DRAW_BARS DRAW_CANDLES DRAW_COLOR_LINE DRAW_COLOR_SECTION DRAW_COLOR_HISTOGRAM DRAW_COLOR_HISTOGRAM2 DRAW_COLOR_ARROW DRAW_COLOR_ZIGZAG DRAW_COLOR_BARS DRAW_COLOR_CANDLES |
Event-driven launch model | OnInit OnStart OnDeinit OnTick OnCalculate OnTimer OnChartEvent OnTester | OnInit OnStart OnDeinit OnTick OnCalculate OnTimer OnTrade OnTradeTransaction OnBookEvent OnChartEvent OnTester OnTesterInit OnTesterDeinit OnTesterPass |
Trading | OrderSend OrderModify OrderDelete The behavior is specified by a separate set of parameters for each function. It complicates writing and debugging programs. | OrderSend One function for all operations. The required behavior is specified in the MqlTradeRequest structure. The response is returned to the MqlTradeResult structure. It is easier to design the behavior, test the result, and debug the program. |
Indicator data buffers | 32 | 512 |
Built-in indicators | Quantity: 30 | Quantity: 38 Indicators are created using handles. The number of copies and memory consumption has been reduced. |
Trading Modes | Hedging | Netting Hedging Stock |
OpenCL and DirectX graphics tools | No | Yes |
Generation of trading robots | No | Yes. At the same time, you can specify custom signal modules. |
Final thoughts
Finally, these programming languages allow you to create various tools to make your trading life more effective. We suggest backtesting, checking, and verifying carefully before using tools on your trading account. You can use these tools to create applications that will make your trading life more profitable.