Watch how to download trading robots for free
Find us on Twitter!
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 - 36


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.

Submit your code

It shows the trend direction for multiple currency pairs on the current time frame.

The indicator plots two Stowell patterns on the right edge of the chart: upper and lower.

The Random EA, which operates by the principle of a coin flip.

The Expert Advisor opens an order by the trading strategy, places a take profit and a stop loss It protects the position by moving the stop loss to breakeven, and maintains it with a trailing stop.

The indicator displays the server time and the time until the current candlestick ends on the М1-D1 timeframes.

The indicator displays the percentage of the price change for the specified period of the specified pairs.

Another interpretation of the moving averages indicators.

The calculation of profit/loss in the deposit currency at the desired symbol price level on all open orders.

24-hour analog GMT(UTC) market clock displaying in background. The clock displays the Greenwich Mean Time and shows the status of all main stock exchanges according to their schedule.

The indicator displays the values of the Moving Averages (MA), deltas between the values and deltas between МАs.

Arrangement of the pending orders at equal intervals (steps).

Tick chart of the price/spread/volume. Saves tick data in a file.

The Moving Average indicator data is used for trading. If the price goes away from the Moving Average by a certain number of points, then an order is placed in the direction of the Moving Average line.

RSI Bollinger Bands are used to establish overbought and oversold RSI regions for generation of short and long trading signals.

Trades on price spikes around important financial announcements.

Price(%)Range is the indicator for the MetaTrader 4, which calculates the price movement based on percentage High (Highest) and Low (Lowest) price on 100 bars.

This is a simple indicator showing pivot only for H1, H4, daily, weekly and monthly.

This code has some functions to close all opened orders once the drawdown reaches a specific percentage of the account balance.

SBVolumeAvg is a Forex Indicator (MetaTrader 4) for calculating Average Volume on the Swing Bars by a ZigZag trend line that is bounded by two vertical lines.

This script plots MQL signal history on a MetaTrader 4 chart.

Easy EA for closing positions with profit or loss. All positions of chart's symbol are counted separately.

This indicator helps you display spread on a chart.

It synthesizes any symbol if you have the source symbols and then makes a real time virtual chart. Same concept with Triangle Hedge (SymbolSynthesizer.mq5 but for chart display in MetaTrader 4.

Draw your preferred pivot formulas: Standard, Fibonacci, Camarilla, Woody’s and DeMark with 4 Support and Resistance lines.

Close, Delete or Clean values from all orders by your choice.

Calculates volume for each currency on pair based on price movement.

Moving average with some extra features.

Simple indicator to show two levels of Standard Deviation Channel on your chart.

This indicator helps determine the end and the beginning of trends based on the inclination of the matches.

The Expert Advisor moves the Stop Loss in the direction of the price movement using various methods.

This indicator will Draw Fibonacci Tools such as Retracement, Arc, Fan, Expansion, Time Zones. Based on ZigZag indicator.

This Expert Advisor uses three indicators: MA(150), RSI(3) with the levels of 80 and 20, Stochastic(6, 3, 3) with the levels of 70 and 30. The direction of opening deals is based on MA. Entry by RSI and Stochastic. Exit by Stochastic.

The Expert Advisor reverses the orders after closing.

A simple indicator, which informs the trader about the appearance of "Bullish Engulfing" or "Bearish Engulfing" candlestick patterns on all timeframes.

Opens orders using the martingale and a virtual trailing stop.

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.