Variable Types in MQL programming language - The #1 Blog on trading, personal investing! Best Tips for Beginners

Header Ads

Variable Types in MQL programming language

In MQL programming language, in variables, constants and functions following variable types are used.
int (integer) – It can only get integer values. 
int Art = 10;           // Integer variable sample
int B_27 = -1;          // Integer variable sample
int Num = 21;           // Integer variable sample
int Max = 2147483647;   // Integer variable sample
int Min = -2147483648;  // Integer variable sample

double (real number) – It is the type that decimal numbers can be define as.
double Art = 10.123;        // Real number variable sample
double B_27 = -1.0;         // Real number variable sample
double Num = 0.5;           // Real number variable sample
double MMM = -12.07;        // Real number variable sample
double Price_1 = 1.2756;    // Real number variable sample

bool (logic variable) – It is the variable that contains only true or false logic values
bool aa = True;     // Logic variable sample
bool B17 = TRUE;    // Logic variable sample
bool Hamma = 1;     // Logic variable sample
bool Asd = False;   // Logic variable sample
bool Nol = FALSE;   // Logic variable sample
bool Prim = 0;      // Logic variable sample

string (text) – It is the variable that contains text
string Prefix = "MetaTrader 4";             // String text variable
string Postfix = "_of_my_progr. OK";        // String text variable
string Name_Mass = "History";               // String text variable
string text = "Upper Line\nLower Line";     // String text variable new line character

color (color) – It is the variable that contains color
color Paint_1 = C'128,128,128';    // Gray color variable sample
color Colo = C'0x00,0x00,0xFF';    // Blue color variable sample
color BMP_4 = C'0xFF,0x33,0x00'    // Red color variable sample
color K_12 = 0xFF3300;             // Red color variable sample
color N_3 = 0x008000;              // Green color variable sample
color Color = 16777215;            // White color variable sample
color Alfa = 32768;                // Green color variable sample
color A = Red;                     // Red color variable sample
color B = Yellow;                  // Yellow color variable sample
color Colorit = Black;             // Black color variable sample
color B_21 = White;                // White color variable sample

datetime (date time) – It is the variable that contains date and time information
datetime Alfa = D'2004.01.01 00:00';      // New year
datetime Tim = D'01.01.2004';             // New year
datetime Tims = D'2005.05.12 16:30:45';   // May 12, 2005 16:30:45
datetime N_3 = D'12.05.2005 16:30:45';    // May 12, 2005 16:30:45
datetime Compile = D'';                   // Compile date D'[compilation date] 00:00:00'