Sie sind auf Seite 1von 5

Kamus MQL4

1. Penulisan One-Line Comment dan Multi-Line Comment


Catatan : Penulisan komentar digunakan untuk menjelaskan kode program
Program yang baik selalu berisi komentar di setiap kode program

2. Konstanta dan Variabel pada MQL4

3. Tipe Data pada MQL4


Catatan : Setiap penulisan variabel atau nama kode untuk fungsi, di haruskan untuk
menuliskan terlebih dahulu jenis datanya sesuai dengan tujuannya

Contoh untuk tipe int :

int Art = 10; // Example integer variable


int B_27 = -1; // Example integer variable
int Num = 21; // Example integer variable
int Max = 2147483647; // Example integer variable
int Min = -2147483648; // Example integer variable
Contoh untuk tipe double :

double Art = 10.123; // Example real variable


double B_27 = -1.0; // Example real variable
double Num = 0.5; // Example real variable
double MMM = -12.07; // Example real variable
double Price_1 = 1.2756; // Example real variable

Contoh untuk tipe bool :

bool aa = True; // Boolean variable аа has the value of true


bool B17 = TRUE; // Boolean variable B17 has the value of true
bool Hamma = 1; // Boolean variable Hamma has the value of true
bool Asd = False; // Boolean variable Asd has the value of false
bool Nol = FALSE; // Boolean variable Nol has the value of false
bool Prim = 0; // Boolean variable Prim has the value of false

Contoh untuk tipe string :

string Prefix = "MetaTrader 4"; // Example string variable


string Postfix = "_of_my_progr. OK"; // Example string variable
string Name_Mass = "History"; // Example string variable
string text ="Upper Line\nLower Line"; // the text contains line feed characters

Contoh untuk tipe color :

color Paint_1 = C'128,128,128'; // The value of gray was assigned to the variable
color Colo = C'0x00,0x00,0xFF'; // The value of blue was assigned to the variable
color BMP_4 = C'0xFF,0x33,0x00' // The value of red was assigned to the variable
color K_12 = 0xFF3300; // The value of red was assigned to the variable
color N_3 = 0x008000; // The value of green was assigned to the variable
color Color = 16777215; // The value of white was assigned to the variable
color Alfa = 32768; // The value of green was assigned to the variable
color A = Red; // The value of red was assigned to the variable
color B = Yellow; // The value of yellow was assigned to the variable
color Colorit = Black; // The value of black was assigned to the variable
color B_21 = White; // The value of white was assigned to the variable

Contoh untuk tipe datetime :

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 4:30:45 p.m.
datetime N_3 = D'12.05.2005 16:30:45'; // May 12, 2005 4:30:45 p.m.
datetime Compile = D''; // equivalent of D'[compilation date] 00:00:00'
4. Cara penulisan Deklarasi dan inisialisasi variabel
a. Satu variabel dapat di deklarasikan dalam satu baris
Contoh :

int Var_1; // Deklarasi variabel dalam satu baris

b. Beberapa variabel dengan tipe yang sama dapat di deklarasikan dalam satu baris
Contoh :

int Var_1, Box, Comm; // Deklarasi beberapa variabel dalam satu baris

c. Variabel juga dapat diinisialisasikan ganda


Contoh :

double Var_5 = 3.7; // Variable initialization in an assignment operator

d. Contoh penulisan yang laiinnya:


 Jenis variabel dengan tipe yang sama dapat di deklarasikan dalam satu baris

 Jenis variabel yang dideklarasikan sendiri, dan pemanggilan berikutnya tidak usah di beri
jenis variabel lagi di depannya

 Pembolehan penulisan deklarasi jenis variabel di dalam suatu operasi perintah

Gambar di atas merupakan pendeklarasian biasa, sedangkan gambar dibawah dibolehkan


pendeklarasian jenis variabel di dalam suatu operasi perintah
5. Jenis Operasi dan Ekspresi pada MQL4
a. Operasi Aritmatika

Simbol Operasi Contoh Analog

+ Penjumlahan x+2

- Pengurangan x - 3, y = - y

* Perkalian 3*x

/ Pembagian x/5

% Sisa Bagi menit = waktu% 60

++ Penambahan 1 dari nilai variabel y ++ y = y +1

- Pengurangan 1 dari nilai variabel kamu-- y=y-1

b. Operasi Penugasan

Simbol Operasi Contoh Analog

= Penugasan nilai x ke variabel y у=x

+= Penjumlahan variabel y oleh x +=x y=y+x

-= Pengurangan variabel y oleh x y-=x y=y-x

*= Perkalian variabel y dengan x y*=x y=y*x

/= Pembagian variabel y oleh x y/=x y=y/x

%= Sisa pembagian variabel y oleh x y% = x y = y% x


c. Operasi Relasi

Simbol Operasi Contoh

== Benar, jika x sama dengan y x == y

!= Benar, jika x tidak sama dengan y x! = y

< Benar, jika x kurang dari y x <y

> Benar, jika x lebih dari y x> y

<= Benar, jika x sama dengan atau kurang dari y x <= y

>= Benar, jika x sama dengan atau lebih dari y x> = y

d. Operasi Logika (Boolean)

Simbol Operasi Contoh Penjelasan

! BUKAN (Logika !х BENAR (1), jika nilai operan adalah SALAH


Negasi) (0); FALSE (0), jika nilai operan bukan FALSE (0)

|| ATAU (Logika x <5 || x> BENAR (1), jika ada nilai dari nilai-nilai itu benar
Disjungsi) 7

&& DAN (Logika x == 3 && BENAR (1), jika semua nilai benar
Penghubung) y <5

e. Operasi Biwise

Das könnte Ihnen auch gefallen