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 and MQL5 Source Code Library

icon

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!

Submit your code

A powerful and feature-rich JSON library for MQL5, designed to bring a modern development experience similar to Python/JS

The EA identifies trade setups by waiting for a user-defined number of indicators (e.g., 2 out of 3) to show divergence simultaneously. This multi-layer confirmation approach filters out market noise. Key Features: Triple Confirmation Engine: Analyzes RSI, MACD, & Stochastic divergence. Advanced Filters: Optional Trend Filter (MA) and Volume Filter for superior signal quality. Full Customization: Control all indicator settings, divergence sensitivity, and trade logic. Professional Risk Management: Use fixed lots or percentage-based money management with SL/TP.

It is an indicator that determines target levels according to the average of price movements.

Tarantella EA: Advanced grid trading system with hedging capabilities and Market Profile integration. Uses ADX trend filtering, Fibonacci-based grid spacing, and multi-layered entry conditions (RSI/ATR/volume) to execute trades only within Market Profile value areas. Features intelligent risk management including trailing stops, breakeven triggers, and partial hedge closing.

Interface for implementing asynchronous execution of algorithms

Profit Maximiser (PMax) Indicator is an indicator created by integrating the moving average of the Supertrend indicator.

BotCilento is a sophisticated grid-trading Expert Advisor for MetaTrader 5 that combines trend-following signals with adaptive risk management.

Zigzag which changes wave direction based on price percentage change on the asset

Historical equity of one-time and one-time open virtual positions to analyse the efficiency of spread/equity trading

This script is a reference solution for mapping symbol names configured by users in MetaTrader 5 EAs or scripts to the actual names provided by the broker. It uses the Levenshtein distance algorithm to automatically identify the most similar symbol in Market Watch. Ideal for developers facing compatibility issues with prefixes or suffixes in symbol names. It is a customisable starting point to suit any specific need.

Breakout Trader 1.0 trades breakouts from the range.

The indicator implements some of the most interesting approaches to measuring correlations

Testing on history in the MT5 tester maths mode.

Indicator Description – Bollinger Bands Crossover Signals Name: Bollinger Bands Crossover Signals Version: 1.1 Author: BENALI Link: https://www.mql5.com/en/users/dahmi_benali

This is an example of ascending sort a struct list by a field. You can find out and customize the above algorithm depending on the purpose of use, this is the most basic example is also a direction to resolve the arrangement in an array of structure. The algorithm used in this example is Quick Sort and Merge Sort.

The Standard fractals are 2 candles to the right and 2 candles to the left. With this Custom Fractals you can choose as many candles as you like, both to the left and to the right.

ATR %, ATR percentage, ATR percentage, ATR percentage, ATR percentage

This expert is a system to help any trader to make a grid of orders.

The Value Area Retracement indicator, is a powerful volume profile-based tool designed to identify key trading levels—Point of Control (POC), Value Area High (VAH), Value Area Low (VAL), and Profile High/Low—across different timeframes. It helps traders spot potential retracement opportunities to the POC, breakout zones, and value areas, making it useful for intraday, swing, and position trading.

A short format for storing ticks.

SmartFibo is a powerful MQL5 custom indicator that automatically draws Fibonacci retracement and extension levels based on the ZigZag algorithm, ideal for trading ABCD patterns. It supports both wick-to-wick and body-to-body Fibonacci calculations, making it versatile for various trading strategies, including JPY pairs.

Unfortunately, I found that some brokers Changing the time on the server is a bit incorrect, which I didn't expect. and which surprised me a lot. Here is a script that anyone can use to check their broker.

Unfortunately I had to realise that some brokers are a bit careless with the server time changeover, which I had not expected and which surprised me a lot. Here is a script with which everyone can check their broker.

EQ

Historical equity of one-time and one-time open virtual positions to analyse the efficiency of spread/equity trading

An indicator that provides a clear visualization of volume pressure on each side of the market

BBMA ZoneZeroLoss Histogram shows trading zones e.g. for "Reentry" setup for risk minimisation

An automated Expert Advisor that implements a popular MACD-based strategy as seen in a viral YouTube video with over 3.5 million views. Combines MACD crossovers, trend filtering with the 200 MA, and support/resistance detection.

A lightweight, customizable tool that displays server time on your chart for precise trading decisions.

Name of expert is 'MultiStrategyEA'

This MetaTrader 5 (MT5) custom indicator, boomSpikeBoxMitigationFinal.mq5, detects a specific bullish spike pattern on the chart and marks entry zones using rectangles and horizontal lines. Once the price returns to ("mitigates") the entry level, the entry line is shortened to the mitigation point.

A class for reading and writing individual bits or bit sequences to and from a buffer.

This indicator detects a specific bearish spike formation over 3 candles

MQL5 script for MetaTrader 5 that adds two buttons to close all buy or sell positions for the current symbol.

This is a simple script file to compute lot size either using risk percentage approach or the actual amount to risk.

The SuperTrend Indicator is a dynamic trend-following tool based on ATR. It plots a colored line above or below price to indicate bullish or bearish conditions. When the price crosses the line, a signal arrow appears. Fully customizable with ATR period, multiplier, arrows, labels, and colors. Suitable for all instruments and timeframes. Ideal for scalping, swing, and intraday trading. Combine it with other indicators for stronger setups.

This simple indicator is to find out easily when the price reaches a particular time on any candle or time frame.

"2 Moving Averages with Bollinger Bands" is a custom MT5 indicator that combines two configurable moving averages and optional Bollinger Bands. It generates real-time Buy and Sell arrows when crossovers occur, with optional alerts, sound, and email notifications. Suitable for all timeframes and symbols

A quick little script to make traders' lives easier. The one thing that always annoys me is resetting the properties like colors for a new chart, to make it look the way i like it. So Here is a script to make things smoother.

An analogue of Period Converter in MT4

Candle Replay Magnifier visually replays historical candles over the current chart area for comparative analysis. This indicator overlays past price bars from a selected date onto the live chart, allowing traders to study candle patterns, volatility, and structure in real time. Includes dynamic range highlighting and detailed tooltips showing open, high, low, close, range, direction, time, and volume for each replay candle.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191