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

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 stripped-down (signal line only) version of Metaquotes' MACD indicator from the MT5==>Indicators==>Examples folder.

This powerful tool filters the classic RSI through a moving average, providing a smoother, more reliable signal line for pinpointing entries, exits, and trend direction with unparalleled clarity.

Instantly calculate the profit and loss potential of your trades directly on the chart. An essential tool for agile and precise risk management.

Intelligent position protection with one-hedge-per-position logic. Features magic number separation, cooldown timer, and max hedges limit. Prevents infinite hedging loops. Free MIT license.

Provide simplest class to write CSV file

Fractal with CCI Filter - Indicator that combines traditional fractals with the CCI filter to reduce false signals. Shows red arrows above the candles for bullish fractals (sell) when the CCI is above the configured threshold and green arrows below the candles for bearish fractals (buy) when the CCI is below the negative threshold. Perfect for identifying reversal points with greater reliability.

Modified standard ZigZag indicator with the addition of information about wavelength in pips, levels and different alerts logic

Adaptive CCI - Commodity Channel Index with dynamically adjusting upper and lower limits based on market volatility. Eliminates fixed thresholds (like 100/-100) by using EMA-smoothed peaks and troughs, providing more reliable overbought/oversold signals tailored to each asset's current volatility. Perfect for identifying high-probability reversal points with adaptive confirmation levels.

Logify is a logging library for MQL designed to simplify debugging, tracking, and monitoring of EAs and indicators. It provides structured, customizable, and organized logs directly on the chart or in the terminal, with support for log levels, flexible formats, and multiple handlers. A lightweight, elegant solution that is easy to integrate into your MQL projects.

Trade server disconnect alerts utility for MT5.

Good afternoon guys, I'm a new student on metatrader5, I'm creating a robot to copy trades from a demo account and save them in a database I'd like some help identifying possible problems, best solutions for the code, etc.

An indicator to detect and mark all popular candle patterns

A lightweight tool for manual scalping in MT5 using keyboard shortcuts

A price increase indicator calculates margin and price changes in per cent.

TardioBot V1.05, named after of a historical figure Giuseppe Tardio, is an Expert Advisor designed for MetaTrader 5 that employs a triangular arbitrage strategy.

Expert Advisor for MetaTrader 5 that combines Exponential Moving Averages (EMA) and Relative Strength Index (RSI) to generate trading signals. Includes risk management features and trading time filter.

The Cincin EA (v2.24) is an automated trading system for MetaTrader 5 that executes conservative random trades on a specified symbol (e.g., EURUSD), with features like basket management, hedging, and position control.

EA Spread lister shows the current, min and max values for all symbols / instruments.

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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191