MQL4 - automated forex trading   /  

MQL4 Book

Login | Register | Language: ru cn en
Update to MetaTrader 4 build 735 and Test the VPS for Free

MQL4 Book  Basics of MQL4

Upgrade to
Book in One File

Basics of MQL4

This section represents basic terms underlying MQL4:

Some basic concepts
Basic terms are described, such as tick (a price change), control in algorithms, and comment in programs. The main event when trading on financial markets is the change of price. This is why tick is an important event that makes the basic mechanisms of MQL4 programs run. What happens when a new tick comes in? What actions should the terminal take? This is control that moves to the forefront here. But, do not forget to comment upon your code.

Constants and variables
The terms constant and variable are introduced, and the difference between these terms is explained. As the term suggests, a constant is something that stays the same, set once for all. Unlike the constant, a variable is a programming code object that can change its content. It is impossible to write a program without using unchangeable objects (constants) and/or objects that can be modified during the program execution (variables).

Data types
Certain types of data are used in any programming language. The data type of a variable is chosen according to its purpose. How can we declare a variable? How can we initialize it (preset its initial value)? A wrong choice of the type for a variable may slow down the program or even result in wrong actions.

Operations and expressions
Operations operate upon operands. What types of operations are there? What is typecasting used for? What are special features of operations on integers? Why is it important to remember about precedences of data of different types? Without knowing about the features of some operations, you can make subtle errors.

Operators
There are simple operators and compound operators. A necessary action should not always be executed by a simple operator. If it is required that a group of operators is executed as one big operator, this group should be included into one compound operator. Requirements and specific examples of using operators are given.

Functions
The necessity of getting a simple code brings us to the term function. In order to use the function from different locations in the program, it is necessary to provide it with function parameters. We will consider the process to create a custom function. Examples of using standard functions are given.

Program types
Scripts, indicators, and Expert Advisors are the types of MQL4 programs that allow you to cover practically the whole class of problems concerning trading in financial markets. It is necessary to understand the purposes of each type of programs in order to use MetaTrader 4 Client Terminal in the best way.