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 Code Library for MetaTrader 5 - 12


This is the largest free source code library for MetaTrader 5 platform programs. Here you can find ready-made Expert Advisors, technical indicators, scripts and libraries. Use the code library when learning MQL5 language and develop your own automated trading applications based on the provided codes.

You can freely download and test published codes, as well as launch them in MetaTrader 5. The library is also available directly from MetaTrader 5 platform and MetaEditor development environment.

Submit your code
latest | best

Random number generation using the 32-bit PCG generator.

Advisor for trading Gbp/Chf. Algorithm for bar opening prices. Timeframe H1.

This indi will draw OBJ_ARROW_BUY/OBJ_ARROW_SELL when find signals on Arrow Indi Buffers.

A fast library for combinations and permutations in MQL.

The script exports summary of closed trades grouped by each trading day to .csv file

Variance (Welford’s method for computing)

The script exports summary of closed trades grouped by each currency pair to .csv file

A script to close all market positions and/or pending orders.

This script will change the SL and TP of all open trades of the symbol to the price where the script is dropped off.

Sell Relative Strengt Index (SRSI)


Average true range

BB stops of MACD with multiple stops



Hull moving average

The Expert Advisor uses four iMA (Moving Average, MA) indicators from two timeframes. Two indicators with averaging periods 1 and 8 are created on the H1 timeframe and two indicators with averaging periods 1 and 8 are also created on the H4 timeframe.

A class to reconstruct closed trades (paired in/out deals) from history sorted by close time.

Display interactive HTML graph of the account balance inside the web browser.

Builds a sliding line with a polynomial of 4 degrees. Extrapolates as a section of a given function with a sinusoid and its axial one. One value is taken from the constructed lines on each bar and a line of extrapolated values is plotted, which does not redraw.

A cross platform library/framework

Exponential moving average

Linear Weighted Moving Average

Advisor scalper. Trading algorithm: Candle[0]> Candle[1] * 2. Taimeframe - 4H && Day.

Simple moving average

Vortex 2

A base class to simplify analyzing trade transactions in MQL5.

This indicator uses the open price for the day, and computes the percent change for that day. Use on any chart TF up to and including D1.

Average trend

RSI of parabolic SAR

RSI with CCI for confitrmation

Corrected AMA

Parabolic SAR of average

Buffer-free indicator implemented on iCanvas

Intra-day Keltner channel extended

Intra-day Keltner channel

Intra-day average true range

This class was developed to exchange data between MetaTrader 5 and CSV files. It converts the strings read from the CSV file to double and integer values depending of the type of the columns. Two producers of CSV files are most important for me. The most important producer are spreadsheet programs, i.e. LibreCalc. Manually entered CSV are the other kind of CSV files I had in mind. Be aware that this class do not use the standard library FileCsv.mqh etc. Instead it works with text files. It splits text lines into fields. Maximum speed and low memory usage were no development goals. This class may not be suited for large datasets or time critical operations. I would not use CSV files if speed was my main goal.

Adaptive moving average - double smoothed

Normalized MACD of averages

RSI Summed