Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

MetaTrader 5 Expert Advisor | MQL5 Programming for Traders – Source Codes from the Book. Part 4

Part 4. Common MQL5 APIs

In the previous sections of the book, we delved into the basics of the MQL5 programming language and studied its syntax, rules of use, and key concepts. However, to write real-life programs employing data processing and automated trading, you should use many built-in functions to interact with the MetaTrader 5 terminal.

In "Part 4. Common MQL5 APIs", we will focus on mastering built-in functions (MQL5 API) and will gradually delve into specialized subsystems. Any MQL5 program can utilize a plethora of technologies and functionalities. Therefore, it makes sense to begin with the most simple and useful functions that can be utilized in most programs.

Among the primary topics, we will study array operations, string processing, file interactions, data conversion, and user interaction functions. We will also explore mathematical functions and program environment management.

MetaTrader Experts, Indicators, Scripts and Libraries

Unlike some other programming languages, using the built-in functions of the MQL5 API does not require additional preprocessor directives. The names of all MQL5 API functions are available in the global context (namespace) and can always be accessed unconditionally.

We will also discuss the possibility of using similar names in different program contexts, such as class method names or custom namespaces. In such cases, you should use the context resolution operator to call the global function, which we discussed in the section on nested types, namespaces, and the context operator '::'.

Programming often requires operations with various data types. In previous sections, we have already seen the mechanisms for explicit and implicit conversion of built-in data types. However, they may not always be suitable for different reasons. To provide more fine-tuned data conversion between different types, the MQL5 API includes a set of conversion functions. Particular attention is paid to functions for conversions between strings and other types, such as numbers, dates and times, colors, structures, and enumerations.


45593