MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal

Automated Trading, Strategy Testing and Optimization Articles

Copy experienced traders' deals with MetaTrader Signals
To post a new article, please log in or register

MetaTrader 5 - More Than You Can Imagine!

| 1 June, 2012 | Views: 117339 | English Russian Chinese Spanish Portuguese

Introduction

The development of MetaTrader 5 started in 2007. MetaTrader 5 was conceived as a revolutionary, multi-market platform that can run on Forex as well as on any other financial market. A lot of work has been done since then, and the result of this work is the platform that provides unlimited opportunities to traders. In this article, we will talk about all the key features of MetaTrader 5 and carry out a comparative analysis with the previous version of the trading platform.

  1. Charts
  2. Navigator
  3. Trading
  4. Toolbox
  5. Testing and Optimization
  6. Integration with MQL5.community
  7. MetaEditor
  8. The MQL5 Programming Language
  9. Services for Traders and Developers


1. Charts

We will start with one of the obvious advantages of the MetaTrader 5 platform, its analytical part. Real-time price charts provide a much wider functionality as compared to MetaTrader 4.

1.1. Customization and 21 Timeframes. Charts in the platform have a variety of different settings, so traders can customize them and adapt to their personal needs. MetaTrader 5 supports three types of charts: a broken line, a sequence of bars and Japanese candlesticks. You can set a separate color to any item in the chart to create the most comfortable work space for long-term work. In comparison with the fourth version of the platform, MetaTrader 5 supports more than twice as many chart periods. Now 21 timeframes are available.

Customizable charts

1.2. Advantage of One-Minute Bars. MetaTrader 5 offers an entirely new principle of storing and passing price data. In the previous version, data on different timeframes were transmitted to the terminals separately. Now, the data is transmitted and stored only in the form of one-minute bars, while higher timeframes are built based on the one-minute bars in client terminals. This approach allows to substantially save traffic, because the history is downloaded only once and applies to all periods. After downloading the price history, the terminal will only download new data.

Now, opening charts is much faster: constructing a chart of any timeframe out of one-minute bars takes a few seconds. Built timeframes are cached on your hard disk. Thus, the next time, the chart with this period will be opened immediately, only new data will be additionally calculated.

Working with the one-minute history also provides full synchronization (matching) of data on all timeframes, since they all use the same one-minute data as a source.

Another advantage of working with the price history is that it is transmitted to client terminals in a compressed format, which saves bandwidth and reduces the download time. For comparison, a 10-year price history of one-minute bars for one symbol is about 10 MB in a compressed form.

1.3. Indicators. The standard MetaTrader 5 delivery pack includes 38 technical indicators. They are conveniently grouped in the Navigator window based on their type: trend indicators, oscillators, volume indicators and Bill Williams' indicators. Available indicators include Bollinger Bands, envelopes, moving average, parabolic SAR, standard deviation, Ichimoku Kinko Hyo, MACD, Bulls Power, Bears Power, Alligator, Awesome Oscillator and many others.

The number of third-party indicators for MetaTrader 5 is practically unlimited. A huge number of indicators is available for download from the Code Base and can be purchased in the market.

1.4. Analytical Tools. The list of available analytical tools has been greatly expanded. Now MetaTrader 5 offers 46 objects, including Elliott, Fibonacci and Gann tools, graphical objects (including objects for interactivity with MQL5 programs), shapes, channels, lines and so on.

Each object has its individual settings — color, line width, additional levels — and will display on different timeframes.

1.5. Precise Time Scale. The precise time scale can be enabled for charts; now, graphical objects are not necessarily linked to bars. Object anchors can be placed in any position between the chart bars. Moreover, when switching between timeframes, the accurate positions of the control points of the object are preserved.

1.6. Economic Calendar. One of the new features of MetaTrader 5 is the economic calendar, which helps perform the fundamental analysis of the markets. Macroeconomic indicators are updated in real time. In addition, the economic calendar events can be easily displayed on the price chart.

Economic Calendar in MetaTrader 5

1.7. More Market Data. In the fourth version, only five values are available for each symbol in real time: Bid, Ask, High, Low and Time. In MetaTrader 5, the amount of available information has increased several times. In addition to the main symbol statistics, you can analyze the real volume and the price of the last deal. Moreover, in the Market Watch tab, over 20 statistical values can be available for each symbol, and all of them are updated in real time.

Market Statistics

An important feature is the availability of real spread and volume values in historical data. These values are stored in each one-minute bar, and thus can be used for testing and optimization of an Expert Advisor in the multicurrency strategy tester of MetaTrader 5.

1.8. Publishing Charts Online. The ability to publish the charts online has been introduced to MetaTrader 5. Now, the terminal allows you not only to save screenshots on your local PC but also to share them with other traders instantly via the special MQL5 Charts service, which is part of MQL5.community. If you have specified your MQL5.community account in the terminal, a screenshot will be assigned to it. Now, you can create your own image gallery and manage it easily via your profile.

Publishing charts online

You can also share your images via the most popular social networking websites.


2. Navigator

The interface of the MetaTrader 5 terminal is now even more convenient. The Navigator window allows you to manage many operations in the terminal, like opening a new demo account or attaching Expert Advisors, indicators and scripts to charts.

2.1. Find a Server by the Broker's Name. Another convenient new feature of MetaTrader 5 is adding brokers' servers by their names. With the previous version, you had to contact your broker to find out the IP address of the trade server or download a special client terminal. Now, you simply enter the name of the broker. The system automatically finds the server with the specified name and adds it to the list.

Find a server by the name of the broker

Then, you can open an account.

2.2. Grouping of Programs. Another convenience of the Navigator is grouping of programs. The technical indicators available in the standard delivery pack are grouped based on their type: trend indicators, oscillators, volume indicators, and Bill Williams' indicators. Custom indicators, Expert Advisors and scripts are also grouped into separate branches. Moreover, a hierarchy similar to the folder structure on a disk is supported within the branches. For example, you can arrange your custom indicators into subfolders /MQL5/Indicators/My/MQL5/Indicators/CodeBase and so on. You will see the same storage structure in the Navigator window.

MQL5 programs purchased through the market are automatically placed in the appropriate subcategory market in Expert Advisors, custom indicators and scripts.

2.3. Further Development of Programs. If you need to modify an application (in case its source code is available), select it and press Enter. The source code of the application will be immediately opened in the MetaEditor.

2.4. Downloads from the Code Base. Through the tight integration of the MetaTrader 5 trading terminal with the MQL5.community services, right from the Navigator, you can start downloading an Expert Advisor, an indicator or a script from the Code Base in just one click. A special command "more" is available in each category of applications. The figure in the command indicates the number of applications available for download.

More applications available in the Code Base

2.5. Rapid Tests. Any Expert Advisor or indicator can be tested in two clicks using the Test context command. The strategy tester will be opened immediately. The only thing you have to do is to set the necessary parameters and run the test.


3. Trading

In MetaTrader 5, trading mechanisms have undergone significant changes as compared to MetaTrader 4. All these changes are aimed at enhancing the use of the trading platform. With MetaTrader 5, you can trade on any stock exchange and through any ECN. The MetaTrader 5 platform has already received the status of an independent software vendor (ISV) for a number of stock exchanges, including SMX, GBOT, CitiBank, Currenex, DGCX, Integral and so on. Further plans are aimed at integration with the major stock exchanges around the world.

3.1. Net Positions. The so-called "netted" accounting of positions is adopted in the MetaTrader 5, which meets the requirements of all modern exchanges. The meaning of netting is that, for one financial instrument, only one position can exist at any given time. Differently directed positions (buy and sell) are not allowed.

Thus, if you have a position to buy one lot of a financial instrument and sell one lot of this instrument, the position will be closed. If you have a position to buy one lot of a financial instrument and buy one more lot, you will have one position of two lots. In this case, the open price is re-calculated; a weighted-average open price is calculated for the position: (Price of the first deal * Volume of the first deal + Price of the second deal * Volume of the second deal) / (Volume of the first deal + Volume of the second deal).

3.2. Six Types of Pending Orders. In addition to market, limit and stop orders, the MetaTrader 5 platform supports two more types of pending orders: Buy Stop Limit and Sell Stop Limit. When such an order triggers, the appropriate type of the limit order is placed. New types of orders enhance the possibilities of implementing trading strategies.

3.3. One-Click Trading. The speed of conducting trade operations is very important in trading. MetaTrader 5 provides the possibility of instant trading in just one click. This feature is available in the Market Watch window.

One-click trading in MetaTrader 5

Besides, the one-click trading function allows users to quickly close positions, delete pending orders, as well as Stop Loss and Take Profit levels in the Trade tab.

One-Click Trading

Quick trading functions are also available in Depth of Market.

3.4. Trading from Chart. MetaTrader 5 provides efficient tools for trading from the chart for traders working manually. Each chart has a removable panel for performing quick market operations.

Trading from Chart

The Intelligent context menu is provided for placing pending orders on the chart. Click the desired order price to place the order. The most probable order type for the current mouse cursor location relative to the price is displayed first.

3.5. Modification of Trade Levels on the Chart. MetaTrader 5 provides the opportunity to change the price of pending orders, as well as of Stop Loss and Take Profit orders directly on the chart. Now, seeing the current situation in the market, you can easily drag a trade level using your mouse in the desired area and then adjust its value more precisely.

Modification of trade levels on the chart

3.6. Asynchrony and Multithreading. As compared with MetaTrader 4, in the fifth version of the platform, traders have more opportunities to implement multiple trading operations at a time. With the previous version, traders could have the error "Trade context is busy", for example, when trading using multiple Expert Advisors simultaneously. In MetaTrader 5, the trade context is wider allowing to send up to 16 trade requests to the server without waiting for the result of their processing.

3.7. Execution of Operations on the Stock Exchange. Through the integration of the MetaTrader 5 trading platform with other systems, now traders can access the leading exchanges around the world. The system allows the direct execution of trade operations in external trading systems (straight-through processing). Trade operations are executed without an intermediary broker (in the Non-Dealing Desk mode).

3.8. Trading from the Depth of Market. An integral part of stock trading is the Depth of Market (DOM). In the DOM, a trader can see the current requests that are really present in the market, as well as see his or her own trade requests. In MetaTrader 5, trade operations can be executed right from the Depth of Market.

Depth of Market in MetaTrader 5

Together with the one-click trading function, the Depth of Market is a powerful tool for scalping allowing users to place, change and remove trading orders in one click.

3.9. Additional Execution Terms. For each trading operation, a trader can specify additional terms of execution by the broker, Fill or Kill (FOK) or Immediate or Cancel (IOC). In the FOK mode, the requested operation should be performed in the specified volume. If the volume of the security is not available in the market, the request should not be processed. The IOC mode implies that the trading operation can be performed for the maximum volume available in the market within the volume specified in the order. If the request cannot be filled completely, an order with the available volume will be executed, and the remaining volume will be canceled.

3.10. Mobile Trading and Push Notifications. Currently, mobile trading is becoming more and more popular. Traders often need to have access to their accounts 24 hours a day, seven days a week, from anywhere in the world. The mobile part of the MetaTrader 5 trading platform is in step with the times. The MetaTrader 5 mobile terminals for iPhone and Android are available to traders absolutely free of charge.

One of the most important functions of the mobile terminals is the option of receiving push notifications. Push notifications are short text messages that can be sent to mobile devices from the PC version of the client terminal, and from various services of the MQL5.community. Such notifications are never lost, and arrive immediately, regardless of whether the application is running or not.

The MQL5 language provides a special SendNotification function, which allows MQL5 programs to send push notifications. Also the terminal allows you to create signals for alerting you of events in the market. One of the event notification types is push notifications.

Push notifications can also be used to obtain information about the updates on the MQL5.community site. To do this, specify your ID in the user profile in the Contacts tab.

Push notifications in MetaTrader 5 Mobile

Push notifications allow traders to always stay informed and react to market changes, even when away from the computer.


4. Toolbox

The Toolbox window, which was available in the fourth version of the terminal, now provides even more functions.

4.1. Exposure. Now the trader can see the summary information about the state of assets for all open positions.

Exposure in the Toolbox window

4.2. Calendar. As already mentioned in section one, MetaTrader 5 now has the calendar of economic events. Macroeconomic indicators are available for more than 10 leading economies of the world, and are updated in real time. All events can be displayed on the charts of the appropriate currency pairs.

4.3. Market. MetaTrader 5 is tightly integrated with the MQL5.community services for traders. The market is a store of MQL5 applications, where anyone can buy a product to use in the terminal. For your convenience, the Market service is integrated into the client terminal.

Market integrated in MetaTrader 5

In the Toolbox window, the trader can see the entire range of applications available in the Market. Before purchasing, you can download a trial version and test it in the strategy tester. In addition, many free applications can be downloaded from the Market.

The list of purchases and downloads is conveniently represented in the Purchases tab. The downloaded/purchased applications are automatically sorted by their type in the Navigator, from which you can run them.

4.4. Code Base. The Toolbox window also provides access to the huge base of free MQL5 source codes. You can download and run any code directly from the terminal. Just drag an Expert Advisor, an indicator or a script to a chart. The code will be automatically downloaded, placed in the appropriate folder, compiled and run on the chart.

Code Base - free source code

Number of published source codes is gradually approaching 1500 and will continue to grow.


5. Testing and Optimization

One of the most important and expected updates in MetaTrader 5 is the multicurrency strategy tester. Now, traders have unlimited possibilities for testing and optimizing the Expert Advisors that trade several symbols.

5.1. Advanced Testing Report. MetaTrader 5 provides an expanded report on the EA testing results. It includes additional statistics, allowing to better evaluate a trading strategy. Now, you can analyze the recovery factor, the Sharpe ratio, position-holding time and many other characteristics. Over 40 characteristics are available in the tester report.

The graphical component of the testing report has also been expanded considerably. In addition to balance and equity graphs, the tester visualizes the time distribution of position entering and profit/loss (hourly, weekly and monthly):

Test result diagrams

In addition, it generates graphs of distribution of profits and MAE/MFE, as well as distribution of profits and position-holding time.

Profit, MAE, MFE and position holding time diagrams

5.2. Increased Accuracy of Every-Tick Testing. The Strategy Tester of the MetaTrader 5 terminal uses only one price-simulation mode in testing — the generation of ticks on the basis of the available one-minute data. Using the M1 timeframe in the tester allows for a very accurate simulation of the price movement with a minimum number of errors, in contrast to the simulation of ticks based on higher timeframes in MetaTrader 4. As a result, the errors in the modeling of prices in the MetaTrader 5 Strategy Tester are trivial, and the differences between the simulated price and the real price can only be within the scale of a one-minute bar.

5.3. More Testing Modes. MetaTrader 5 has four modes of testing: every tick (the most accurate method), one-minute OHLC (testing on the bar support points), open price only (a rough method for rapid testing), mathematical calculations (for mathematical computations in the strategy tester without the use of historical data and generation of ticks).

5.4. Custom Optimization Criterion. In MetaTrader 4, the trader was able to optimize an Expert Advisor by one of the five available criteria. In the fifth version, one more standard criterion is available (the product of the balance and the Sharpe ratio). However, the main new feature is the possibility to use a custom optimization criterion. By selecting the Custom max value in the tester settings, you can optimize your Expert Advisor by the maximum value returned by OnTester().

5.5. Optimization Cache and XML Report. The testing results are stored by the terminal into a special cache of results (which is an XML file), for a quick access to them when they are needed. During a test or an optimization, for each set of input parameters the terminal searches the result cache for already available results from the previous runs, in order to avoid re-runs. If the result with such a set of parameters is not found, the agent is given the task to run the testing.

Since the optimization result cache is a standard XML file, you can analyze it in external applications (for example in MS Excel).

5.6. Automatic Download of History and Synchronization of Timeframes. The MetaTrader 5 Strategy Tester provides the availability of all the necessary historical data. Before testing, it downloads all the available historical data for the required symbol. This is done only before the first run. Further, only the new data are loaded. If during testing, an Expert Advisor (a multi-currency one) requests data for other symbols, they are also automatically loaded from the trade server.

5.7. Forward Testing. MetaTrader 5 offers the new forward testing mode. Forward testing is a re-run of the best optimization results on a different time period. This feature allows you to avoid parameters fitting in certain areas of historical data.

5.8. Stress Testing. To make the EA testing conditions close to real, use the Random Delay mode in MetaTrader 5. From the moment of request sending till its execution the price can change. Depending on the deviation set in the order, it can be executed at the current price (if it is within the deviation) or a requote can be sent. Testing in this mode allows you to correctly code processing of such situations.

5.9. Multi-Threaded Optimization. The Strategy Tester is multi-threaded and allows the use of all available computer resources. Testing and optimization are carried out using special computing agents that are installed as services on the user's computer (one agent on each core). Agents work independently and allow parallel processing of optimization passes.

5.10. Testing Clouds of Remote Agents. You can connect an unlimited number of remote agents, that are the agents installed on other computers, to your strategy tester. Use the special application MetaTester to install testing agents on each test computer in your local network, and then connect them to the strategy tester in one client terminal. The agents will receive computation tasks over the network and return the results to the client terminal. Thus, you can significantly expand the capabilities of parallel computing, and several times accelerate the optimization process.

5.11. MQL5 Cloud Network. The MQL5 Cloud Network allows organizing the exchange of computing resources between those who need them, and those who can provide idle CPU time of their computers. With the MQL5 Cloud Network, a trader can use the computing power of thousands of agents around the world. Optimization, which would take several years if using only one computer, can now be run in a few hours.

MQL5 Cloud Network

To use the network, just open the strategy tester and enable the use of cloud agents.

In addition to using the MQL5 Cloud Network, you can provide your CPU computing power in the network and earn money. To do this, you do not even need to install the MetaTrader 5 client terminal. Download the specially created installer that allows you to quickly and easily install MetaTester, an application for managing remote agents on the computer. After a simple setup, you join the MQL5 Cloud Network and start earning. Statistics on the use of the network and your earnings for the CPU power provided is conveniently collected in your profile on the MQL5.community website. Information about agents will appear in your profile immediately after they fulfill their first task.

5.12. Ease of Agents Management. You can easily manage testing agents via the context menu. In a couple of clicks you can enable/disable any type of agents: local, remote or MQL5 Cloud Network. Also, here you can control connected remote agents, as well as import and export configurations of agents.

5.13. Mathematical Calculations. The features of the strategy tester combined with the possibilities of the MQL5 Cloud Network are not limited to testing and optimization of Expert Advisors. The "Mathematical Calculations" testing mode allows you to perform any calculation. In this mode, the strategy tester does not load or use the price history and information about the symbols, but simply performs calculations, calling the OnInit(), OnTester() and OnDeinit() functions. Mathematical computations are useful for calculating an extremum of a mathematical function, whose value should be returned from OnTester(). Optimization is conducted for finding the maximum value of the function.

5.14. 2D and 3D Visualization of Optimization Results. Better to see once than hear a hundred times. In the strategy tester, you can analyze optimization results in visual mode. Here is the two-dimensional visualization of the optimization. The darker the shade of green, the higher the value of optimization criterion is.

2D visualization of optimization results

Below is a three-dimensional mode of visualization of mathematical calculations in the strategy tester. The picture shows the search for the maximum of the function f(x,y) = MathSin(x^2 + y^2) + k * MathExp(-p * x^2 - p * y^2).

3D visualization of optimization results

5.15. Visual Testing. The visual testing mode allows you to visualize exactly how the Expert Advisor performs trade operations during testing on historical data. The visualizer is also available in MetaTrader 4, but in the fifth version of the terminal, its functionality has been greatly expanded. First, the visualizer was available only separately from the terminal. Now it runs as a separate process. Trade operations are not only displayed on the chart of the symbol tested. In separate tabs, you can follow the current account balance, open positions and current orders, the history of trade operations, as well as a detailed log.

Strategy Tester Visualization

5.16. Any Custom Results During Optimization. Each time you start an Expert Advisor in the strategy tester, you can create your own data array. This data set can be saved using the FrameAdd() function in a special structure called a frame. During the optimization of an Expert Advisor, each agent can send a series of frames to the terminal. All the received frames are written in the file *.MQD in the folder terminal_directory/MQL5/Files/Tester named as the Expert Advisor. They are written in the order they are received from the agents. Receipt of a frame in the client terminal from a testing agent generates the TesterPass event that can be handled using the OnTesterPass() function. This allows dynamically processing the results of optimization without having to wait for its completion.

5.17. Acceleration Usng OpenCL. A number of calculations performed in Expert Advisors can be carried out using video cards due to the native support of OpenCL in the MQL5 language. Modern video cards contain hundreds of small specialized processors that can simultaneously perform simple mathematical operations with incoming data streams.

Using OpenCL in MQL5 applications can accelerate testing and optimization of Expert Advisors hundreds of times. Test agents (local, remote or cloud ones) automatically select the fastest calculation method: CPU or video card.

For example, calculation of the well-known Mandelbrot Fractal is performed a hundred times faster using OpenCL compared to CPU.


6. Integration with MQL5.community

The MetaTrader 5 client terminal is tightly integrated with the MQL5.community. The MQL5.community provides unique services to traders and developers.

6.1. Market. Right from the terminal, you can purchase any ready-made application in the store of MQL5 programs. Before purchasing, you can download a trial version and test it in the strategy tester.

Anyone can become a seller in the Market service. You only need to submit an application. After the registration of your Seller status is approved, you can sell your products and earn money.

6.2. MQL5 Cloud Network. The powerful distributed computing network is available for testing and optimization of your Expert Advisors in the strategy tester. Thousands of optimization sessions can now be performed in a few minutes. In addition to using the network, you can provide your own computing capacities and earn.

6.3. MQL5 Storage. MQL5 Storage is a personal storage of source codes integrated into the MetaEditor. It allows you to keep your code safe and access it from anywhere in the world. MQL5 Storage stores the entire history of changes to the uploaded files, which can be viewed at any time. In addition, you can revert to any previous versions of a file.

6.4. Code Base. With one click, you can download and run any code published in the Code Base section of the MQL5.community site. Just drag an Expert Advisor, an indicator or a script to a chart. The code will be automatically downloaded, placed in the appropriate folder, compiled and run on the chart.

6.5. Signals. The Signals service allows users to subscribe to trading signals from professional traders, get them directly in their client terminal and execute trade operations based on them.

6.6. Articles. Various useful articles on the MQL5 programming language and the platform have been published on the MQL5.community website. Find the required article in the convenient list of subjects and descriptions that is available in a separate tab of the Toolbox window right in the MetaEditor.

Access to the articles at MQL5.community

6.7. MQL5 Charts. MetaTrader 5 allows traders to publish their screenshots online via the MQL5 Charts service. Your screenshot can be automatically published online right after you have made it. You will also get the link to share your image via one of the most popular social networking websites.

If you have specified your MQL5.community account in the terminal, a screenshot will be assigned to it. This will allow you to create your own image galleries and manage them via your profile easily.


7. MetaEditor 5

The built-in programming language has always been one of the most important parts of the MetaTrader trading platform. Application development is not just the MQL5 programming language, whose undoubted advantages will be proved below, but this is also the editor in which you work with the source code. MetaEditor 5 provides a lot of new features that were unavailable for MetaTrader 4 users.

7.1. The New File System. As in the previous version, MetaEditor can only work within its own file system sandbox, the /MQL5 folder inside the data folder of the terminal. For better convenience, each type of source file has its own directory (Experts, Indicators, Scripts, Include and so on). The structure of folders and files that store executable programs (Expert Advisors, indicators and scripts) is displayed in the Navigator window of the client terminal.

A convenient file system

7.2. The MQL5 Wizard. MetaEditor 4 includes a wizard for creating Expert Advisors allowing to generate templates for developing various applications. In the fifth version of MetaEditor, this component has been significantly redesigned. Its new name is the MQL5 Wizard. It still allows you to create templates of programs that are already properly designed and contain the necessary event handlers. However, the main new feature is the possibility to generate ready-to-use Expert Advisors. The trader must choose which signals the Expert Advisor will use, its money management strategy and the way it will be protected from losses (type of trailing stop).

The MQL5 Wizard

Now the trader does not necessarily need to know how to program in MQL5, to get a ready-to-use Expert Advisor. An EA is generated in a few easy steps. Then you can start optimizing your Expert Advisor in the strategy tester.

7.3. MQL5 Storage. MQL5 Storage stores personal MQL5 source codes. It is designed for the versioned storing of files and project management directly from MetaEditor in a handy manner.

The source code is stored in a secure remote repository, which can be accessed through your MQL5.community account. In case of hard disk failure, your local copy of codes can be quickly restored from storage.

You can access your storage from any computer. Just log in using your MQL5.community account in MetaEditor. You can work with the storage using the convenient context menu of the Navigator window.

The MQL5 Storage

Each transaction of changes in the storage is logged. Later, you can view the entire history of changes, compare versions of files using a special tool, as well as revert to any previous version.

Comparing files

The options of MQL5 Storage will continue to expand. It will enable joint work with projects using the storage by giving permissions to the required MQL5.community accounts.

7.4. Fast Compilation of C++ DLL. Many developers use third-party DLLs when developing applications in MQL5. With MetaEditor 5, you do not need to use MS Visual Studio for compiling DLL. The editor supports standard cpp and h-files and compiles them as easily as the MQL5 source code. If MS Visual Studio is installed on your computer, its compiler is used. Otherwise, the required files are sent to a special compilation server via a secure connection. After compilation the ready DLL file is sent back to you.

Like with the MQL5 source code, all compilation results, including errors and warnings, appear in the Error tab of the Toolbox window.

7.5. Intelligent Code Control. MetaEditor 5 provides various tools that allow you to speed up the process of code writing, make navigation easier and prevent errors.

Snippets. For ease of writing code, MetaEditor provides the possibility to insert snippets, small template fragments of source code describing a particular construction of the MQL5 language. Insertion of a snippet is initialized by typing the keyword.

Autosubstitution of Function Names. It is the possibility to view the variants of names of built-in and custom functions, constants, variables, class members, keywords and so on to insert when writing code. The variants of names are determined by the first characters typed.

Tips on the Function Parameters. With this feature, the developer does not need to read the documentation of every function when writing code. When describing a function, just press a certain key combination and the MetaEditor will display a hint with the function parameters and types of these parameters.

List of Functions. In the MetaEditor, you can view the list of all functions declared in the current file and quickly move to any of them.

7.6. Code Styler. A well-structured and correct design of the source code makes work with such a code much easier. A carefully formatted code looks professional. MetaEditor provides the Styler Function. Any code can be transformed into a well-designed one by a single click. The formatting rules used in the styler have been developed by professional programmers with years of experience.

7.7. Code Highlighting. Compared to version four, MetaEditor 5 provides wider opportunities to highlight different elements of the source code (keywords, function names, variables and so on). Each user can create individual code highlighting.

7.8. Support for Unicode. The previous version of the editor does not support source code files in Unicode. This causes problems when viewing and compiling files that contain characters, which are not supported in the current locale of the operating system. In MetaEditor 5, this problem is completely solved. Any source file can be saved in the Unicode format using the standard editor features, and then you can work with it and compile it with any language of your operating system.

7.9. Inserting Resources. The MetaEditor 5 focuses on the maximum ease of the programming process. The routine operation of inserting the resource file into the program is performed with a single command.

Inserting resources

7.10. Global Search and Integration with MQL5.community. When developing a program, you often need to access a variety of information. MetaEditor solves this problem by integrating with MQL5.community. Articles and source codes published on mql5.com are conveniently tabbed in the Toolbox window. However, for a really effective use of available information, a search system is required.

MetaEditor 5 includes the global search system.

Search system in MetaEditor 5

You type your request in the single search box, choose where to search and get results in a separate tab of the Toolbox. In addition to searching separately in the current document, files, Articles or Code Base, you can search the entire MQL5.community site. It includes the Forum, Articles, Documentation and Code Base.

7.11. Debugging. Without exaggeration, everyone who used the MetaEditor 4 wanted the debugging function. The appearance of the debugger in the fifth version has raised the development of MQL5 applications to a new level. All standard functions are available for debugging applications.

Breakpoints. Place breakpoints in the source code lines, where the process of program execution must be interrupted to study the behavior of the program.

Watching Expressions. Follow the values of any expressions during debugging in a separate tab of the Toolbox.

Call Stack. Watch the call stack during debugging.

Step-by-Step Debugging. Use the commands of the step-by-step debugging: Step Into, Step Over and Step Out.

Debugging

7.12. Projects. One of the many planned features in the MetaEditor 5 is project management. This will facilitate the work by structuring the developer's programs.

7.13. Code Profiling. Debugging in MetaTrader 5 has greatly simplified the work of programmers. But, MetaEditor 5 has another powerful tool for source code optimization. Code Profiler detects all application bottlenecks.

Code profiler

Code profiler analyzes the execution speed of the application's individual source code fragments. Analysis results are submitted to a programmer both by individual functions and lines. Thus, it is now possible to find the slowest parts of the code and optimize MQL5 program operation.


8. The MQL5 Programming Language

8.1. Increased Speed. Compared with MQL4, the speed of execution of the MQL5 code has increased 4 to 20 times! The speed ​​of execution has almost reached the level of the C++ language, so in MQL5, you do not need to use third-party DLL to speed up calculations. In fact, the lack of DLL improves application security.

8.2. Code Protection. With MetaTrader 5, you can enjoy a new high level of protection of executable files of MQL5 programs (ex5). Protection against decompilation has increased due to the following factors: new, more complicated encryption algorithms, file integrity checking (checking that the file has not been changed after compilation) and the greater complexity of the language. Programs that are sold through the Market service are additionally encrypted and bound to the user's hardware (computer configuration), which further protects them.

8.3. Similarity to C++. The syntax of the MQL5 language is very similar to one of the most popular programming languages, C++. Therefore, it is easy to learn, and you can easily translate programs from other modern programming languages into MQL5. MQL5 is object-oriented and allows you to take advantage of this programming approach - encapsulation and extensibility of types, inheritance, polymorphism, overloading and virtual functions.

8.4. Classes and Structures. MQL5 supports complex or abstract data types: structures and classes. They are used to describe not only the object, but also the model of behavior. The fact that the object is responsible for its own behavior greatly simplifies the task of programming for users of this object.

8.5. Events. The MQL5 language provides processing of a number of predefined events. Only three events are available in MQL4, while in the fifth version, 13 types of events can be handled, including the events of application initialization and deinitialization, the receipt of a new tick, change of price data and depth of market, timer events, trade events, events of testing, optimization and actions with charts.

8.6. Management of Charts, Objects and Resources Directly from MQL5. You can manage all the chart properties, add, modify and delete objects from the chart directly from MQL5 applications. When combined with the possibility to handle events of interaction of a user and a chart, you can create graphic panels of any complexity.

In addition to working with built-in objects, you can use your own graphics and sound resources.

8.7. New Indicator Drawing Styles. In MetaTrader 5, the number of drawing styles of indicators has increased from 6 to 18. You can draw lines, histograms, symbols, filled areas, candlesticks, arrows and so on. Here is the indicator with the filled area between the two lines, drawn in the chart subwindow.

Indicator with the filled area between the two lines

8.8. Ease of Work with Indicators. In MQL4, the direction of indexing in indicator buffers is permanent, from the most recent (0) to the oldest data. This approach is acceptable when working with indicators and scripts. However, when developing indicators, such indexing is inconvenient, since with each new bar, the indexing of all elements is shifted by one, and a new element with the 0 index is added at the beginning of the array. In MQL5 the problem has been solved by adding the ArraySetAsSeries function, which allows you to change the direction of array indexing.

In MQL5 the number of indicator buffers used is unlimited, whereas in MQL4 you can use no more than eight buffers.

Also in MQL5, you can develop indicators which are based on the values ​​of other indicators. In the fourth version of the platform, an indicator could be built based on another indicator only through a special option in the interface of the client terminal. In MQL5, you can pass to an indicator any handle of another indicator as the input data array price[].

8.9. A Huge Standard Library and a Lot of Examples. The standard delivery of MetaTrader 5 includes a large standard library written in MQL5. It makes program development easier, providing easy access to the MQL5 functions. The standard library contains classes for organizing data, working with files, strings, graphical objects, charts, indicators and trade classes.

Also, MetaTrader 5 includes many examples of the source code of all types of applications (Expert Advisors, indicators and scripts).

8.10. OpenCL Support. MQL5 has native support for OpenCL. To use all of its benefits, you do not need third-party libraries. Simply use specialized MQL5 functions. The OpenCL language is used for performing computations on video cards that support OpenCL 1.1 or higher. Modern video cards contain hundreds of small specialized processors that can simultaneously perform simple mathematical operations with incoming data streams. The OpenCL language organizes parallel computing and provides greater speed for a certain class of tasks.


9. Services for Traders and Developers

An integral part of the MetaTrader 5 trading platform is the MQL5.community. In addition to the site where traders and developers can find useful information and discuss issues related to MetaTrader 5, MQL5.community provides participants with a variety of unique services.

The MQL5.community has its own secure payment system which is used in all the community services. You can deposit money to your account via WebMoney and PayPal, as well as using a credit or a debit card. Withdrawals can be made to a WebMoney or a PayPal account. All transfers are made through a secure encrypted SSL connection.

9.1. Jobs. The Jobs service is useful for both traders and programmers. If a trader needs to implement any trade idea, but does not know how to program in MQL5, he can always contact a professional developer. On the other hand, the developers have an excellent opportunity to capitalize on their knowledge.

The Job service has a user-friendly interface, allowing you to place a public order and choose the most advantageous offer from the programmer, or publish an order for a specific developer. The process of executing the order is divided into several steps that include confirmation to help avoid misunderstandings and disagreements between the customer and the developer.

The Jobs service

In the event of a dispute, you can apply to arbitration, which is conducted by MetaQuotes Software Corp.

The service was launched two years ago, and about 1,300 jobs have been fulfilled since then.

9.2. Market. The Market service is an open secure site for buying and selling MQL5 applications. The Market is available online at the MQL5.community site and can also be accessed directly from the client terminal. All the applications that are offered for sale are additionally protected. When downloading, the application is encrypted and bound to the configuration of your computer.

9.3. MQL5 Storage. MQL5 Storage  for source code is designed for the versioned storing of files and project management directly from MetaEditor in a handy manner. With MQL5 Storage, you can access your source code from any computer using an MQL5.community account. If you are working on different computers, you can easily synchronize the source codes and always work with their latest version.

9.4. MQL5 Cloud Network. The MQL5 Cloud Network allows organizing the exchange of computing resources between those who need them and those who can provide idle CPU time of their computers. With the MQL5 Cloud Network, a trader can use the computing power of thousands of computers around the world. Optimization, which would take several years if using only one computer, can now be run in a few hours.

9.5. Signals. MetaTrader 5 Trading Signals is a service allowing traders to copy the trading operations of a Signals Provider. Any trader can subscribe to signals and follow the strategy of an experienced trader. The service is absolutely secure; each Signals Provider is registered in the public monitoring system containing the detailed information about the provider's trading activity.

MetaTrader 5 Trading Signals

The showcase of available trading signals can be found both on the MQL5.community web site and in the client terminals. Subscriptions can be made using an MQL5.community account. Traders can easily manage their subscriptions via their profiles or "My Signals" section.

Any trader can subscribe via the Toolbox window of the Signals tab in MetaTrader 5 client terminal.

Trading Signals Directly in MetaTrader 5

There is no need to arrange any agreements with a Signals Provider; all necessary actions are performed strictly inside the system. No commission is charged for using the signals. After subscription, the Provider's trading operations will be copied to the Subscriber's account almost instantly.

If you are a successful trader and would like to make money using your experience and skills, you can register as a provider in the Signals service via the MQL5.community web site. The trading account is connected to the monitoring system where the detailed information about it will be displayed. The account will be included in the list of available trading signals both on MQL5.community and directly in the trading terminal.

Signal Monitoring

If trading signals are provided for a fee, payment from traders will be delivered to the Provider's internal MQL5.community payment account.


Conclusion

In this article, we have tried to list all the key features of the MetaTrader 5 platform. Of course, the functionality of the trading platform is even wider. MetaTrader 5 provides a full range of tools necessary for successful trading in financial markets. It should also be noted that the development of the trading platform continues and its opportunities keep expanding. We keep up to date and follow the development of the industry, communicate with the leading stock exchanges, brokers and, of course, traders to provide the best trading platform for you.


Translated from Russian by MetaQuotes Software Corp.
Original article: http://www.mql5.com/ru/articles/384

Last comments | Go to discussion (5)
Jin
Jin | 1 Jun 2012 at 07:14
Great product!
onewithzachy
onewithzachy | 2 Jun 2012 at 01:16

Imagine this :

1. When we click the close button, a window pop out asking "Are you sure to close MetaTrader 5 ?". Simple tools to prevent MetaTrader 5 from being close while running EA. 

2. Copyright protection for .mq5 and .ex5. Add mql5 command line/function to secure delete any .mq5 and/or .ex5.    

 

ALL not available - service desk replied - "not in near future". 

:( 

Joaquin Poudereux
yokinfx | 21 Nov 2012 at 10:33

I would like to ask... 

I would want to translate this document to Spanish and publish it in my website, www.funciondelgrafico.com, just because I've been asked lots of times articles regarding what's new in MetaTrader 5 platform.

I mean to mention the original version of the article, pointing to this url, but my site is mainly aimed at spanish people.

I would like to ask for permission to Metaquotes to do this. I understand this translation would be good for your company, but I just wanted your permission.

 

Regards, and keep up the good work! 

phi nuts
phi.nuts | 21 Nov 2012 at 11:23
yokinfx:

I would like to ask... 

I would want to translate this document to Spanish and publish it in my website, www.funciondelgrafico.com, just because I've been asked lots of times articles regarding what's new in MetaTrader 5 platform.

I mean to mention the original version of the article, pointing to this url, but my site is mainly aimed at spanish people.

I would like to ask for permission to Metaquotes to do this. I understand this translation would be good for your company, but I just wanted your permission.

 

Regards, and keep up the good work! 

Write to Service Desk ask for permission from them.
Joaquin Poudereux
yokinfx | 21 Nov 2012 at 14:53
phi.nuts:
Write to Service Desk ask for permission from them.
Thanks, that's what I've done.
A Few Tips for First-Time Customers A Few Tips for First-Time Customers

A proverbial wisdom often attributed to various famous people says: "He who makes no mistakes never makes anything." Unless you consider idleness itself a mistake, this statement is hard to argue with. But you can always analyze the past mistakes (your own and of others) to minimize the number of your future mistakes. We are going to attempt to review possible situations arising when executing jobs in the same-name service.

OpenCL: The Bridge to Parallel Worlds OpenCL: The Bridge to Parallel Worlds

In late January 2012, the software development company that stands behind the development of MetaTrader 5 announced native support for OpenCL in MQL5. Using an illustrative example, the article sets forth the programming basics in OpenCL in the MQL5 environment and provides a few examples of the naive optimization of the program for the increase of operating speed.