Skip to content

Integer Types

Integer Types

In MQL5 integers are represented by eleven types. Some types can be used together with other ones, if required by the program logic, but in this case it’s necessary to remember the rules of typecasting.

The table below lists the characteristics of each type. Besides, the last column features a type in C++ corresponding to each type.

TypeSize in BytesMinimum ValueMaximum ValueC++ Analog
char1-128127char
uchar10255unsigned char, BYTE
bool10(false)1(true)bool
short2-32 76832 767short, wchar_t
ushort2065 535unsigned short, WORD
int4- 2 147 483 6482 147 483 647int
uint404 294 967 295unsigned int, DWORD
color4-116 777 215int, COLORREF
long8-9 223 372 036 854 775 8089 223 372 036 854 775 807__int64
ulong8018 446 744 073 709 551 615unsigned __int64
datetime80 (1970.01.01 0:00:00)32 535 244 799 (3000.12.31 23:59:59)__time64_t

Integer type values can also be presented as numeric constants, color literals, date-time literals, character constants and enumerations.

Additional integer type aliases (for C/C++ compatibility)

To simplify the porting of code from other languages, such as C and C++, aliases for standard integer types were added to the MQL5 language. These aliases do not introduce new types, but are alternative names for existing types in MQL5. They can be used in all contexts where base types are applicable.

TypeCorresponds to MQL5 typeSize in BytesSignMinimum ValueMaximum Value
int8_tchar8signed-128127
uint8_tuchar8unsigned0255
int16_tshort16signed-32 76832 767
uint16_tushort16unsigned065 535
int32_tint32signed- 2 147 483 6482 147 483 647
uint32_tuint32unsigned04 294 967 295
int64_tlong64signed-9 223 372 036 854 775 8089 223 372 036 854 775 807
uint64_tulong64unsigned018 446 744 073 709 551 615

These aliases are useful when porting existing libraries and algorithms from C/C++ to MQL5, especially in projects with a high level of platform compatibility. All new names are available in scripts, EAs and indicators.

See also

Conversion Functions, Numerical Type Constants

Last updated on