Download MetaTrader 5

Watch how to download trading robots for free

Find us on Facebook!
Join our fan page

Access the CodeBase from your MetaTrader 5 terminal

Couldn't find the right code? Order it in the Freelance section

How to Write an Expert Advisor or an Indicator

MQL5 Source Codes of Libraries for MetaTrader 5

Libraries are small sub-programs containing a certain functionality that can then be used for developing new applications. Once written and thoroughly checked, a library allows users to speed up the development of new MQL5 applications. One of the illustrative examples is ALGLIB library containing multiple numerical analysis functions.

Library source codes can be downloaded and used in MetaEditor when developing trading strategies. They cannot be launched in MetaTrader 5 independently.


Complete and fast functions similar to Bars and iBarShift from MQL4.

A library to provide simple storage mechanism for expert advisors and indicators.

Handy functions for comparison and rounding of floating-point numbers (prices, lots and money).

A module of trading signals based on the Moving Average indicator signal module.

A module of trading signals based on the Moving Average indicator signal module.

Printing GetLastError() and MqlTradeResult retcode as text description.

Increased accuracy of the standard timer.

The EasyAndFastGUI library allows creating graphical interfaces for custom MQL programs.

A module of trading signals based on the signal module of the iCCI (Commodity Channel Index, CCI) indicator.

A library for creating analog clocks using MetaTrader 4/5 graphical resources.

A library for common rounding methods used in MQL development, primitive wrapper class for type (double), and vector for CDouble objects. MQL5 and MQL4 compatible!

An implementation of the dictionary (associative array) data structure in MQL5, based on CArrayObj and CList.

A library for creating icons in the Windows taskbar and for sending text alerts. The use of this library will help you make your MQL programs more informative.

A library for working with chart subwindows.

A library for reading/writing the parameters of arbitrary Expert Advisors.

A library for working with traditional and custom symbols

Measuring the net performance of MetaTrader 4/5 strategy testers.

The MetaTrader 4/5 library allows generating reports based on the trading history.

Returns the profit of a position in points, as well as commission, swaps and profit in money based on the trading history.

The class monitors the emergence of a candlestick

MqlParams container class that uses method chaining to quickly add params and reduce lines of code.

Many traders are interested in native work with the BTC-e exchange directly from MetaTrader. In the exchange API, it is necessary to send data with the confirmation of parameters validity through HMAC-SHA512. The algorithm of SHA512 and HMAC calculation is implemented in this class.

The library makes indicators' Init/Deinit synchronized

Original mathematical functions taken from different places, which either do not have analogues or perform much faster than alternative implementations

This time-series library brings lightning-fast timeseries access to MQL5 for time-sensitive applications while implementing the familiar methods of MQL4, e.g. iBarShift.

A module of trading signals based on the Moving Average indicator signal module.

The CDir class allows getting information about files and folders outside the MQL5 sandbox similar to the MS-DOS Dir command. Call of system DLL is used, therefore you should allow their use.

Returns position profit in points based on the trading history.

The library allows to automatically assign 'magic' to an Expert Advisor on any symbol and any timeframe. It allows having up to 65535 magic numbers in one Expert Advisor.

A library of averaging algorithms, the algorithms were described in details in the article "Averaging Price Series for Intermediate Calculations Without Using Additional Buffers"

Libraries for the interaction of МТ4/5 with R

The class allows to easily determine from your MQL5 programs any changes in the Market Watch window (change of symbol sorting, adding, deleting a symbol or a set of symbols), as well as opening and closure of charts, and the availability of the one click trading option on the current chart, on which the program is running.

The function returns the number of positions opened by an Expert Advisor for the day.

Module of trading signals of the "Candels High Open" custom indicator for analyzing High and Open of the last three bars.

Here are 6 classes, designed for convenient and intuitive use of indicators in your code.

Constructor for creating histograms of statistical distributions of indicators, timeseries and their derivatives.

Version of the iBarShift function for the MetaTrader 5, takes a parameter of type datetime — opening time of the bar, the index of which must be found.

Class for exchanging data between programs. It allows to pass structures of arbitrary size via the global variables of the terminal from one program to another.

This library allows to automate the process of connecting to a trade server after the "Account disabled" error occurs.

Parallel use of the MetaTrader 4 and MetaTrader 5 order systems.