ตัวดำเนินการในภาษา MQL4 เป็นสิ่งจำเป็นที่เราจะต้องเข้าใจก่อนการเขียนโปรแกรม
Arithmetical Operations: ตัวดำเนินการทางคณิตศาสตร์
| 
Symbol | 
Operation | 
Example | 
Analog | 
| 
+ | 
Addition of values  เพิ่มค่า | 
x + 2 | |
| 
- | 
Subtraction of values or sign change ลบ | 
x - 3, y = - y | |
| 
* | 
Multiplication of values คูณ | 
3 * x | |
| 
/  | 
Quotient of division หาร | 
x / 5 | |
| 
% | 
Residue of division หารเอาเศษ | 
minutes = time % 60 | |
| 
++ | 
Addition of 1 to the value of the
  variable เพิ่มค่า +1 | 
y++ | 
y = y + 1 | 
| 
-- | 
Subtraction of 1 from the value of the
  variable ลบ - 1 | 
y-- | 
y = y - 1 | 
Assignment Operations: ตัวดำเนินการเครื่องหมาย
| 
Symbol | 
Operation | 
Example | 
Analog | 
| 
= | 
Assignment of the value x to the variable
  y , ให้ค่าเท่ากับ            | 
у = x | |
| 
+= | 
Increase of the variable y by x ,  เพิ่มค่าเท่ากับ x | 
у += x | 
y = y + x | 
| 
-= | 
Reduction of the variable y by x ,ลดค่าเท่ากับ x | 
y -= x | 
y = y - x | 
| 
*= | 
Multiplication of the variable y ,by x | 
y *= x | 
y = y * x | 
| 
/= | 
Division of the variable y ,by x | 
y /= x | 
y = y / x | 
| 
%= | 
Residue of division of the variable y by
  x  | 
y %= x | 
y = y % x | 
Relational Operations : ตัวดำเนินการลำดับขั้น
| 
Symbol | 
Operation | 
Example | 
| 
== | 
True, if x is equal to y ,จริงถ้าค่าเท่ากัน     | 
x == y | 
| 
!= | 
True, if x is not equal to y ,จริงถ้าค่าไม่เท่ากัน  | 
x != y | 
| 
<  | 
True, if x is less than y ,จริงถ้า x<y | 
x < y | 
| 
>  | 
True, if x is more than y ,จริงถ้า x>y | 
x > y | 
| 
<= | 
True, if x is equal to or less than y ,จริง ถ้า x<=y          | 
x <= y | 
| 
>= | 
True, if x is equal to or more than y, จรืงถ้า x>=y | 
x >= y | 
Boolean (Logical) Operations : ตัวดำเนินการด้านตรรกศาสตร์
| 
Symbol | 
Operation | 
Example | 
Explanations | 
| 
! | 
ไม่ใช่ | 
! х | 
 คืนค่าจริง ถ้าค่าไม่เท่ากับ x | 
| 
|| | 
หรือ | 
x < 5 || x > 7 | 
 คืนค่าจริง ถ้า X <5 หรือ X > 7  | 
| 
&& | 
และ) | 
x == 3 && y < 5    | คืนค่าจริงถ้า X= 3 และ Y < 5 | 
Comma Operation
เป็นตัวคั่นระหว่าง Expression ซึ่งถูกใช้ใน Loop หรือ Function Call ซึ่งจะกล่าวในบทความต่อไป 
| 
for(i=0,j=99;
  i<100; i++,j--) Print(array[i][j]); // Loop statement | 
| 
My_function
  (Alf, Bet, Gam, Del) // Calling for a function with arguments | 
สามารถชมการอธิบายเรื่อง Operations and Expression คลิปด้านล่าง
 
ไม่มีความคิดเห็น:
แสดงความคิดเห็น