MQL4 Data Types

Overview

MQL4 programs operate on data of various types. Data types influence processing speed and internal representation. Integers are processed fastest, followed by floating-point numbers (using a co-processor), and then strings (due to dynamic memory allocation). Price data is of double precision.

Basic Data Types

  • **Integers:** char, short, int, long, uchar, ushort, uint, ulong.
  • **Logical:** bool.
  • **Literals:** ushort (for symbol constants).
  • **Strings:** string.
  • **Floating-point:** double, float.
  • **Color:** color (represented internally as an integer).
  • **Date and Time:** datetime (represented internally as an integer).
  • **Enumerations:** enum.
  • Complex Data Types

  • **Structures:** struct.
  • **Classes:** class.
  • **Interfaces:** interface.
  • Type Characteristics

  • **Arithmetic Types:** Integer and floating-point types are considered arithmetic. Processing speeds vary: integers are fastest, double is slower due to co-processor, and string is slowest due to memory management.
  • **Visualization/Input Types:** color and datetime types are primarily for visualization and parameter input in Expert Advisors or custom indicators. They are stored as integers.
  • **Typecasting:** Implicit type casting is used in expressions. Explicit type casting can be specified.
  • Related Concepts

  • **OOP:** Complex data types are abstract data types in the context of Object-Oriented Programming.
  • **Typecasting:** Detailed information available at /basis/types/casting.
  • **Integer Types:** Detailed information available at /basis/types/integer.
  • **String Type:** Detailed information available at /basis/types/stringconst.
  • **Real Types:** Detailed information available at /basis/types/double.
  • **Structures, Classes, and Interfaces:** Detailed information available at /basis/types/classes.
  • **Void Type and NULL Constant:** Detailed information available at /basis/types/void.
  • **User-defined Types:** Detailed information available at /basis/types/typedef.
  • **Object Pointers:** Detailed information available at /basis/types/object_pointers.
  • **References:** Detailed information available at /basis/types/this.