You are on page 1of 2

Introduction to MQL4 - MQL4 Tutorial

Page 1 of 2

MQL4 Book

Introduction to MQL4

Preface Table of Contents Introduction to MQL4 Basics of MQL4 MetaEditor Program in MQL4 Operators Variables Programming in MQL4 Programming of Trade Operations Simple Programs in MQL4 Standard Functions Creation of a Normal Program About Complex Programs Appendixes
Use the opportunities of MQL5 in MetaTrader 5

Introduction to MQL4 Programming


Before starting to study MQL4 programming, we will define the scope of our study. First of all it should be noted that programs discussed in this book can be used only as applications for working in MetaTrader 4 Client Terminal. Fig. 1 below shows the role of these programs in trade management. For a better understanding of the importance of these programs in trade management, let's look at Fig. 1.

Want to study new MQL5? Read MQL5 Reference

Download MetaTrader 4 Client Terminal

Fig. 1. A program in MQL4 as a part of MetaTrader 4 Client Terminal.

If you are interested in MQL4 programming, you must have got acquainted with the client terminal. Client terminal is a part of the online trading system. This system also includes a server installed in a dealing center. The dealing center in its turn is connected with other market participants - banks and financial institutions. The client terminal includes informational environment - a set of parameters that inform about the market state and relations between a trader and dealing center. It contains information about current prices, limitations on the maximal and minimal order size, minimal distance of stop orders, allowance/prohibition of the automated trading and many other useful parameters characterizing the current state. The informational environment is updated when new ticks are received by the terminal (green line in Fig. 1).

Built-In Tools
The client terminal contains built-in tools that allow conducting technical analysis of market and execute manual trading management. For market analyzing one can use technical indicators and different line studies support/resistance lines, trend channels, Fibonacci levels etc. For manual trading management the order management toolbar is used. Using this toolbar a trader can open, close and modify orders. Besides, the terminal has the option of automated management of stop order position. A trader's actions with built-in trading management tools result in the formation of trade orders, which are sent to a server. For more information about the "Userguide" (ClientTerminal_folder\Terminal.chm). client terminal please refer to

Programming Tools
Market analyzing and trade management in MetaTrader 4 Client Terminal is implemented with the help of programming tools. MQL4 language allows creating such programs. There are three types of applications created

mk:@MSITStore:F:\Documentatie\MQl4BookEnglish.chm::/intro.html

3/25/2012

Introduction to MQL4 - MQL4 Tutorial

Page 2 of 2

in MQL4 and intended for working in the client terminal: custom indicator - a program for graphical displaying of market regularities written according to an author's algorithm; Expert Advisor - a program that allows to automate a large part of trading operations and fully automate trading; script - a program for executing one-time actions including execution of trade operations. Fig. 1 shows that the application has the same means of access to the client terminal informational environment as built-in tools for manual trading (blue arrows). It also can form managing influences (red arrows), passed to the client terminal. Programs of different types can be used simultaneously and exchange data. Using these applications a programmer can automatize a large part of trading operations or create a robot that will trade without a trader's interference. Applications and manual management tools can be used in the client terminal simultaneously complementing each other. The fundamental technical characteristic of trading using the online trading system MetaTrader is that all managing actions are produced in the client terminal and then sent to a server. Application programs (Expert Advisor, script, indicator) can work only as part of the client terminal provided it is connected to a server (dealing center). None of application programs are installed on the server. The server allows only to process signals coming from a client terminal. If a client terminal is disconnected from the Internet or an application program (Expert Advisor or script) running in it does not generate any managing actions, nothing will happen on the server. The scope of our study includes programs (Expert Advisors, scripts and custom indicators) that allow to conduct partially or fully automated trading and significantly widen the informational maintenance of trading (see Fig. 1). In this book you will find the description of program components and the main rules of creating and using programs. We will also consider in details examples of programs and parameters of informational environment of the client terminal, which are available to a program during its execution. Programs for the automated trading possess much more potential possibilities than manual tools of trade management. In the majority of cases a program allows to make a trader's job easier eliminating the necessity of a constant tracking of market situation sitting before a computer for a long period of time. It may also help to relieve nervous tension and lower the number of errors appearing in periods of extreme emotional tension. But the main thing is that using of the program method of trade management allows to develop one's own ideas and test them on historical data, select optimal parameters for applying these ideas and, finally, to implement a thought-out trading strategy.

Table of Contents

Basics of the Language

2000-2010, MetaQuotes Software Corp. All rights reserved.

mk:@MSITStore:F:\Documentatie\MQl4BookEnglish.chm::/intro.html

3/25/2012

You might also like