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

MQL4 Source Code Library for MetaTrader 4 - 20

The largest library features codes of free trading Expert Advisors, technical indicators and scripts. With the available applications you can trade in automated mode and analyze price dynamics. Use the library of codes to learn more about financial market sentiments.

Download free applications, test them and run in your MetaTrader 4. You can access them from the MetaTrader 4 platform and the MetaEditor development environment.


The script analyzes the market based on two criteria: the moving averages and the support and resistance levels.

The function returns the lot size, which is calculated based on the stop loss size and the risk specified in the variable.

The function closes all locked orders. This really saves money on the spread.

Implementation of a trading system based on divergence detection.

The indicator registers the price level breakout moments and the significance of these levels.

The indicator shows the High, Close and Low of the previous day, week or month with time shift.

The function allows the execution of the specific code in the specified time interval.

The Expert Advisor trades based on the support/resistance levels set by the user, while trailing the Stop Loss order.

The Expert Advisor places a grid of pending orders in both directions several minutes before the specified time and trails the Stop Loss order after the orders trigger.

Tick volumes drawn by days as a histogram of clusters.

Tick volumes of a specified interval drawn as histogram of clusters.

An indicator template that draws arrows on the chart.

Script that closes orders and (or) deletes pending orders.

Indicator with several Moving Averages.

Tick volume of the candlestick drawn as clusters.

The Expert Advisor is based on the "On the MaZi" strategy.

The converter of the tick files created with the Ticks collector into different data representation formats.

Signal based on the ZigZag indicator.

A small improvement of the little known TVI indicator (

Collection of ticks with writing data to a file and plotting non-standard charts.

The idea behind the Expert Advisor is based on the volatility explosion in the pulse waves.

The Expert Advisor based on the "New Trading Dimensions" book by Bill Williams.

The virtual trailing stop can place stop loss, take profit and trail the order in a way that they are not visible to the broker.

Simple Expert Advisor based on the RSI indicator.

A trend strategy based on moving averages with colors as in a traffic light. The purpose of writing the EA — to test the strategy on history and pick working parameters.

The channel indicator. It also displays the current channel levels as price labels and the type of the signal for making trading decisions.

The indicator displays the series of waves, breakthrough points and targets for Take Profit.

The indicator performs the calculation of the derivative of the price.

The lookup and display of the divergences of different classes based on the data of the base indicator.

The Expert Advisor watches the market orders and generates a sound signal after a predefined time from the moment of order opening.

Elementary trailing stop able to distinguish its "own" orders among others by comment and/or Magic number. It also distinguishes the financial instrument that needs to be trailed.

The indicator marks the pin bars on the chart based on the parameters set.

The Expert Advisor is based on the Williams Percent Range indicator. It sells in the overbought zone and buys in the oversold zone. Trailing Stop and operation timer are attached to it.

The Moving Average indicator values are used for trading.

This indicator downloads history of symbols which have open charts. It will no longer be necessary to wait for an update when switching timeframes.

This EA implements a grid strategy by placing buy and sell orders at the same time.

Just a Donchian channel with slope. If xslope=0 it becomes the Donchian channel. It uses the moving average of Momentum.

The script tests the computer in 45 performance tests. It is possible to compare the performance of VPS/VDS servers.

This ZigZag indicator uses dual buffers to store high and low points.

EA opens trades from support and resistance levels, which were set by a trader, and revolves them at another levels.