MQL4 Language Basics

Overview

MQL4 (MetaQuotes Language 4) is an object-oriented, high-level programming language designed for creating automated trading strategies and custom technical indicators for financial markets. It is based on the C++ programming language and supports advanced features such as enumerations, structures, classes, and event handling. MQL4 simplifies interaction with external applications via DLLs by expanding its built-in data types. Its syntax is similar to C++, easing the transition for developers familiar with modern programming languages.

Core Concepts

  • **Object-Oriented Programming (OOP):** MQL4 incorporates OOP principles.
  • **Event Handling:** Supports mechanisms for handling events.
  • **DLL Interaction:** Facilitates communication with external applications through Dynamic Link Libraries (DLLs).
  • Language Structure

    The MQL4 language is organized into the following main sections:

  • **Syntax:** Rules governing the structure of MQL4 code.
  • **Data Types:** Defines the kinds of data that can be used, including enumerations and structures.
  • **Operations and Expressions:** How data is manipulated and combined.
  • **Operators:** Symbols used to perform operations.
  • **Functions:** Reusable blocks of code.
  • **Variables:** Named storage locations for data.
  • **Preprocessor:** Directives processed before compilation.
  • **Object-Oriented Programming:** Concepts like classes and inheritance.
  • **Updated MQL4:** Information on recent language changes.
  • Resources

  • **Online Documentation:** Available at [docs.mql4.com](https://docs.mql4.com/en).
  • **Help Files:** Downloadable CHM files for offline use (English, Russian).
  • **Community:** Forum, CodeBase, Articles, Freelance services.
  • Platform Integration

    MQL4 is used within the MetaTrader 4 trading platform. Downloads for MetaTrader 5 (which also supports MQL5) are available for various operating systems including Windows, macOS, Linux, iOS, and Android.