説明や使い方などを自由に書き込んでくださいm(..)m


メタエディタで和訳MQL言語リファレンスを参照できるようにする方法


文法(Syntax)

コメント(Comments)
識別子(Identifiers)
予約語(Reserved words)


Syntax of MQL4 is much a C-like syntax, apart from some features:

no address arithmetic;

no operator do ... while;

no operator goto ...;

no operation of [condition]?[expression 1]:[expression 2];

no compound data types (structures);

complex assignments are impossible; for example, val1=val2=0; arr[i++]=val; cond=(cnt=OrdersTotal)>0; etc.;

calculation of a logical expression is always completed, never early terminated.

コメント(Comments)

Multiline comments start with /* symbols and end with */ symbols. Such comments cannot be nested. Single comments start with // symbols, end with the symbol of a new line and can be nested into multiline comments. Comments are allowed where blank spaces are possible and tolerate any number of spaces.

和訳:
・・・

識別子(Identifiers)

Identifiers are used as names of variables, functions, and data types. The length of an identifier cannot exceed 31 character.

Symbols you can use: numbers from 0 to 9, Latin capital and small letters a to z, A to Z (recognized as different symbols), the symbol of underlining (_). The first symbol cannot be a number. The identifier must not coincide with any reserved word.

予約語(Reserved words)

The identifiers listed below are fixed reserved words. A certain action is assigned to each of them, and they cannot be used for other purposes:

データタイプ(Data types)

型キャスト(Type casting)
整数定数(Integer constants)
リテラル定数(Literal constants)
真偽値型定数(Boolean constants)
浮動小数点数型定数(Floating-point number constants)
文字列定数(String constants)
色定数(Color constants)
日付時刻定数(Datetime constants)


Any program operates with data. Data can be of different types depending on their purposes. For example, integer data are used to access to array components. Price data belong to those of double precision with floating point. This is related to the fact that no special data type is foreseen for price data in MQL 4.

Data of different types are processed with different rates. Integer data are processed at the fastest. To process the double precision data, a special co-processor is used. However, because of complicity of internal presentation of data with floating point, they are processed slower than the integer ones. String data are processed at the longest because of dynamic computer memory allocation/reallocation.

The main data types are:

Integer (int)
Boolean (bool)
Literals (char)
Strings (string)
Floating-point number (double)
Color (color)
Date and time (datetime)
The color and datetime types make sense only to facilitate visualization and enter those parameters that had been set from expert advisor property tab or custom indicator "Inputs" tab. The data of color and datetime types are represented as integer values. int and double are called arithmetic (numeric) types.

Only implicit type casting is used in expressions.

型キャスト(Type casting)

Only implicit type casting is used in MQL 4 expressions. The type priority grows at casting:

int (bool,color,datetime);
double;
string;
Before operations (except for the assignment ones) are performed, the data have been conversed into the maximum priority type. Before assignment operations are performed, the data have been cast into the target type.

Examples:

int i = 1 / 2; // no types casting, the result is 0
int i = 1 / 2.0; // the expression is cast to the double type, then is to the target type of int, the result is 0
double d = 1.0 / 2.0; // no types casting, the result is 0.5
double d = 1 / 2.0; // the expression is cast to the double type that is the same as the target type, the result is 0.5
double d = 1 / 2; // the expression of the int type is cast to the target type of double, the result is 0.0
string s = 1.0 / 8; // the expression is cast to the double type, then is to the target type of string, the result is "0.12500000" (the string containing 10 characters)
string s = NULL; // the constant of type int is cast to the target type of string, the result is "0" (the string containing 1 character)
string s = "Ticket #"+12345; // the expression is cast to the string type that is the same as the target type, the result is "Ticket #12345"

Type casting is applied to not only constants, but also variables of corresponding types.

整数定数(Integer constants)

Decimals: numbers from 0 to 9; zero must not be the first number.

Examples:

12, 111, -956 1007
Hexadecimals: numbers from 0 to 9, letters from a to f or A to F to represent the values 10 to 15; they start with 0x or 0X.

Examples:

0x0A, 0x12, 0X12, 0x2f, 0xA3, 0Xa3, 0X7C7
Its internal representation is a long 4-byte integer number. Integer constants can assume values from -2147483648 to 2147483647. If the constant exceeds this range, the result is undefined.

リテラル定数(Literal constants)

Any single character enclosed in single quotes or a hexadecimal ASCII-code of a character looking like '\x10' is a character constant of integer type. Some characters like a single quote ('), double quote (") a question mark (?), a reverse slash (\), and control characters can be represented as a combination of characters starting with a reverse slash (\) according to the table below:

line feed NL (LF) \n
horizontal tab HT \t
carriage return CR \r
reverse slash \ \\
single quote ' \'
double quote " \"
hexadecimal ASCII-code hh \xhh
If a character different from those listed above follows the reverse slash, the result will not be defined:

int a = 'A';
int b = '$';
int c = '©'; // code 0xA9
int d = '\xAE'; // symbol code ®
Its internal representation is a long 4-byte integer number. Literal constants can assume values from 0 to 255. If the constant exceeds this given range, the result is undefined.

真偽値型定数(Boolean constants)

Boolean constants may have the value of true or false, numeric representation of them is 1 or 0, respectively. True or TRUE, False or FALSE can be used, as well.

Examples:

bool a = true;
bool b = false;
bool c = 1;
Its internal representation is a long 4-byte integer number. Boolean constants can assume the values of 0 or 1.

浮動小数点数型定数(Floating-point number constants)

Floating-point constants consist of an integer part, a point (.), and a fractional part. The integer and the fractional parts represent sequences of decimal numbers.

Examples:

double a = 12.111;
double b = -956.1007;
double c = 0.0001;
double d = 16;
Its internal representation is a double-precision number of 8 bytes. Floating-point constants can assume values from -1.7 * e-308 to 1.7 * e308. If a constant exceeds this range, the result is undefined.
×

この広告は1年以上新しい記事の投稿がないブログに表示されております。