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

MQL4 and MQL5 Source Code Library

You don't know where to start learning the MQL5 or MQL4 programming language? Various programs for your MetaTrader terminal are available here. Download and study published code examples, develop your own indicators and Expert Advisors. Publish your applications in the largest library of MQL5 and MQL4 codes, and they will be available in every MetaTrader terminal and MetaEditor.

Your code examples in MQL4 and MQL5 will be distributed worldwide, and thousands of traders will know about you!

To post a new code, please log in or register

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

Bollinger bands - squeeze

Squeeze - on chart candles or bars

Squeeze indicator

RSI swings

Aroon oscillator - multi time frame version

Aroon - multi time frame version

Set the number of consecutive candles along with RSI level for a valid signal.

Kalman filter - with candles or bars, multi time frame version