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
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.
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.