Section 3 - Syntax and Basic Things
Syntax of this MQL4 similar c / c + +.
We go one by one
1. Variable Declaration and Naming
valid:
code:
double aa;
double aaa,bbb;
double aaaa=1;
double bb,cc=2;
double a=0,b=1;
double d=2,
e=3,
f=4; double data type that it can be replaced
int, string, bool, etc.
a-f is the name variablenya.
so essentially (the most simple)
code:
tipe_data nama_variabel = value;
that are used to coding, such as the above combination
can also be used
I want to be constrained even though changed by the
user, just add extern
so:
code:
extern tipe_data nama_variabel = value
well, the name variable is case sensitive. Nama_Variabel
different same nama_variabel
for the array, will be explained in other parts. (usually
if beginners rarely use an array)
rules for naming variables:
- Max length 31 characters
- Must start uppercase, lowercase, or _ (not numbers
or symbols other than _)
- Can not use the keyword
examples keyword: bool, color, extern, static, Case,
Else, If, true, false and others
2. Comment
to write a comment, there are 2 ways
1. add / / at the beginning of the sentence
2. use / * * /
example
code:
stoploss int = 10; / / stoploss of trade
or
code:
/*
Stoploss filled in the point
* /
stoploss int = 10;
sentence after / / on the same line will not be read
by any program and followed by / * and * / will not
read by the program.
Hopefully useful to all
of us ..
Click the register when
you are ready!
Section 4 -
Data Type: the type of data on MQL4 with examples.
|