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

MQL5 Source Code Library for MetaTrader 5

icon

This is the largest free source code library for MetaTrader 5 platform programs. Here you can find ready-made Expert Advisors, technical indicators, scripts and libraries. Use the code library when learning MQL5 language and develop your own automated trading applications based on the provided codes.

You can freely download and test published codes, as well as launch them in MetaTrader 5. The library is also available directly from MetaTrader 5 platform and MetaEditor development environment.

Submit your code

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.

The Pending_tread EA is a versatile and easy-to-use trading robot designed to automate the placement and management of multiple pending orders arranged in a grid pattern above and below the current market price. This EA is well-suited for scalping strategies and can operate on any timeframe or currency pair, making it highly flexible for various trading styles.

Volatility indicator with a threshold line based on the Generalized AutoRegressive Conditional Heteroskedasticiticy (GARCH) statistical model used for time series analysis and forecasting.

The AutoTrendLines indicator automatically draws support and resistance trend lines on your MetaTrader 5 chart. It identifies key price levels using two methods: Two Extremums (Type 1) or Extremum and Delta (Type 2). The lines are recalculated only when a new bar forms, ensuring efficient performance.

Set Auto TP and SL: The “Set Auto TP and SL” (Take Profit and Stop Loss) feature is a crucial tool in any trading strategy, designed to automate risk and reward management. It allows traders to define fixed price levels where a trade should be automatically closed to either secure profits (TP) or limit losses (SL), removing the need for constant manual monitoring. When this feature is enabled, each position you open will automatically include a predefined Take Profit and Stop Loss level based on your custom parameters, such as a specific number of pips, percentage of balance, or technical levels. This not only saves time but also ensures that your trades are protected from sudden market movements and emotional decision-making.

Monthly VWAP (Volume Weighted Average Price) is an essential MQL5 indicator that calculates and displays the Volume Weighted Average Price for each trading month. It's a powerful tool for understanding long-term market sentiment, identifying key monthly fair value, and informing strategic decisions.

Weekly VWAP (Volume Weighted Average Price) is a powerful MQL5 indicator that calculates and displays the Volume Weighted Average Price for each trading week. It's a crucial tool for identifying weekly fair value and understanding the underlying sentiment over a longer timeframe.

Daily VWAP (Volume Weighted Average Price) is a simple yet powerful indicator that calculates and displays the Volume Weighted Average Price for each trading day. Ideal for identifying intraday fair value and supporting your daily trading decisions.

The Watermark indicator is lightweight and efficient, designed to display an informative watermark over the main MetaTrader 5 chart. It automatically shows the current symbol, chart time and asset description, allowing traders to customise their interface with style and convenience.

Trend Equilibrium Indicator TrendEQ dynamically analyses market trends by combining momentum and volatility. By measuring momentum against market trends, TrendEQ provides a reliable measure of trend strength and direction.

The RiskManagement library in MQL5 provides efficient and dynamic risk management, optimised to minimise resources. It allows setting maximum profit and loss limits with customisable modifiers. It includes OCO order control and tools for candlestick management and price conversions.

A compound interest calculator for the trader. Calculates, based on your parameters, your risk of ruin, and the optimal risk per trade. Gives a forecast of your capital size in a year, month, and at the end of the term.

CryptoTrend 1.00 Expert Advisor is an automated trading system designed for trading cryptocurrency (in particular, BTC). Main features: Bollinger indicator: Used to identify market extremes and generate buy and sell signals. Order Block filtering: Allows to find support and resistance levels, which helps to reduce the number of false signals. Self-learning: The entry threshold is adapted depending on the statistics of winning and losing trades, which allows the Expert Advisor to adapt to changing market conditions. Risk management: Calculates stop loss (SL) and take profit (TP) levels based on risk analysis and correlation

Custom time and price scale.

A Simple RSI and Moving Average-Based Expert Advisor for MQL5

The "Candle_size.mq5" indicator was developed to display the size of candles on the chart, providing a clear and detailed visual analysis of price movements. It calculates the difference between the high and low prices of each candle and displays the formatted value as text next to the corresponding candle. This feature is especially useful for traders who want to assess volatility or identify specific patterns of price behaviour.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190