Compiled
A compiler converts a code. In general, it functions as a code processing tool and prepares operations of the machine. If the program is not written correctly, it will show an error and stop the execution of script. MQL4 compiler can be downloaded on the MTDownloads website for free.
While developing applications for the trading terminal, one needs libraries for MetaTrader 4. They are small programs that do not perform any independent commercial or analytical function and cannot be launched. They are designed to facilitate and accelerate development of robots in MQL4. In particular, libraries accumulate frequently used blocks of custom programs for further distribution.
Role of a compiler in developer’s work
Obviously, the terminal is written in a particular programming language, in our case, it is of the fourth generation. Accordingly, a user can create trading robots and bots for active trading in the terminal using MQL4.
Currently, programming in MQL4 is the most popular way, because the 5th version is still not fully developed. There is a big difference in the compilers of these two versions, so the transition from 4 to 5 version will not be smooth. In general, you will need to adjust if you decide to write a bot for trading platform of the fifth generation.
When writing your own bot in MQL4, the first step is to create a script. You have to create a logic of action with the help of the functions to implement the algorithm. How does it happen? The "handler" function runs the diagnostics of quotations for a specified asset and compares the risks of the transaction. The second stage is a hint for a trader or full execution of the transaction.
No doubt, you should remember that every line of the code written by you should pass through a compiler for MetaTrader to read it.
Features of MQL4
If you are interested in creating a trading bot, have a look at the basic characteristics of the MQL4 language:
- Simplicity – it is easy to learn any programming language for everyone familiar with this area;
- Working with charts – you can create a full-fledged handler of quotes and get information in a convenient format;
- The MQL4 language is in the class of C-like, which allows the use of standard paradigms and rules of OOP;
- To create a trading robot, one needs to learn how to work in the MetaEditor environment. An indispensable part of a developer’s activities is work with the code of a compiler.
Libraries – a trader’s assistants
Code libraries can considerably simplify the process of developing scripts in MQL. This is a set of ready-made scripts that you can just use in the right situation and not to prescribe the functions separately. The mechanism is based on the paradigms of OOP.
Functionality is divided into clusters, and a user can load the selected applications from any class using the base file. It is easy to use the library, and besides, it will speed up the process of the code writing.
To use any library, you need to install it and connect to your local platform:
- First, upload and select an app in the context menu;
- All applications of the Code Base library run easily – you must drag the application in the area of the price chart. The script is determined and loaded by the locating system.
Library solutions has already been developed by professionals; they do not require upgrading. If you are ready to develop your scenario of trading, it better to use experience of professionals.
Creation of libraries
If you still want to create a unique library of MQL functions, it can be done without problems! To do it, you need to open Metaeditor of the trading terminal. In the open window, you enter the name of the library and copy the desired features, for example, GetLot(), NewOrder(), DelOrders(), DelOrder(), EditOrder() and CloseOrder(). You should note that you need to specify additional parameters for some functions. If this stage was completed successfully, you can simply connect the created library to trading assistants and scripts that can be downloaded on the MTD website.
To sum it up, the MetaTrader 4 trading platform looks unique for a trader. All beginners can use a demo account and work with the browser-based version, while professionals are already engaged in deep personalization and development via MetaEditor and MQL language. Compilers for codes and libraries became indispensable for developers of scripts and bots. With their help, one can implement an individual approach to trading.