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

Top MQL4 and MQL5 source codes based on user ratings - 4

Submit your code

A chart-based risk monitor for prop-firm style rules: draws a live “Dead-Line” price level showing where your Daily Loss Limit or Overall Max Drawdown would be violated, based on equity, open exposure, and optional trailing drawdown.

Automates MQL5 buffer and plot index management. Eliminates manual counting, simplifies Z-order layering, and handles complex plot types (Candles, Color Lines) with a single line of code.

Adaptive VWAP Institutional: Multi-Asset Auto-Detection & DST-Accurate Session Resets (Forex 5PM NY Standard).

A professional on-chart panel for instant lot size and risk calculation. Essential for manual traders using strict risk management.

If you have access to the Expert Advisor code, you can save balance and equity charts and calculate additional optimization criteria by adding additional code from this library.

A comprehensive stop-loss and trade management module offering multiple stop-loss methods (Fixed Pips, ATR-based, Swing High/Low, and Percentage) and trailing stop options (Fixed, ATR, Step, and Breakeven). It includes automatic broker stop-level adjustment, risk-reward–based take profit calculation, and visual stop-loss lines on the chart. The code follows a clean, structured architecture with a dedicated `CStopLossManager` class, standardized enums and structures, and fully documented English comments for clarity and maintainability.

Download all OHLC data history available and save it in a file, either for just one symbol or for many in Market Watch

NeuroPro Verbalisation Converter for MQL5

Modern Time Panel for MT5 The Modern Time Panel is a sleek, minimalist custom indicator for MetaTrader 5 that helps you track time with precision. Fixed neatly at the top-right corner of your chart, it displays the current Broker Time, Local Time, and a live countdown to the next candlestick (New Bar). Built with an independent 1-second timer, the countdown continuously runs even when the market is slow or there are no incoming ticks. Fully customizable and dark-mode friendly, it is the perfect non-intrusive tool to ensure you never miss a candle close.

Draws the previous day High, Low, and Close as horizontal reference lines on the chart for a configurable number of past days. Yesterday's levels extend into today as live support and resistance, with optional touch alerts.

A strict Multi-Timeframe Price Action Expert Advisor that trades based on precise OHLC conditions across different timeframes simultaneously. It features pending order entries, role reversals, and dynamic risk management without using any lagging indicators.

This Expert Allows You To Run and Play DOOM (The Game) on MetaTrader5! It's A Take On The Infamous "Can It Run Doom?" Challenge.

A professional trade management utility that completely hides your Stop Loss and Take Profit levels from brokers. It features a Spread Protector to prevent virtual stop-outs during news events or daily rollovers.

An advanced quantitative filter based on Chaos Theory and fractal geometry, it calculates the intrinsic dimensionality of the price curve to instantly classify market regimes into trending or mean-reverting states.

KSQ Command Centre is a production-ready, two-way bridge between MetaTrader 5 and Google Sheets. It was originally designed to help fund managers and quantitative traders remotely monitor and manage large, funded accounts (e.g., Darwinex Zero, Prop Firms, PAM, MAM) directly from a mobile browser, without needing to log in to a VPS. This Expert Advisor not only exports data—it actively listens for commands typed into your Google Sheet and executes them in MT5 in near real-time.

Educational MT5 chart utility that monitors XAUUSD spread on the chart and alerts when spread rises above user-defined warning or danger levels.

Library for trading session control. At startup it counts the time of trading sessions for all 7 days of the week (on Sat and Sun there can be cryptocurrency trading), up to 10 sessions per day. Then in OnTick() you can do checks, and if a tick came in outside the trading session, you can exit further processing of it.

The source codes written during the development of the library for creating multi-currency Expert Advisors that combine many instances of various trading strategies.

Modification of the standard indicator Fractal

Engulfing Bar Occurs below Ema moving Average that is rising - Buy Trade -

This service periodically checks swaps for predefined symbols and saves detected changes into CSV-files for further analysis and potential replay (not implemented here). Also it monitors and alerts swap changes of existing positions.

PrintXYZ() library to print massive information from the terminal.

Price Action Day Trader is a robust, trend-following MQL5 Expert Advisor designed for intraday trading. It focuses on high-probability price action patterns Pin Bars, Engulfing Candles, and Inside Bar Breakouts while filtering trades through a dual Moving Average trend filter.

Indicator Description – Candle Close Timer Name: Candle Close Timer Version: 1.0 Author: BENTRADE TRADING Link: https://www.mql5.com/en/users/dahmi_benali

In Part 6 of the "MQL5 Programming for Traders", we will study a key component of the MQL5 language – trading automation. We will start with a description of the fundamental entities, such as financial instrument specifications and trading account settings. These are prerequisites for creating properly operating Expert Advisors.

Alligator beginner tutorial to learn how to code in MQL5

This is an indicator with a rainbow-like display, both for trend or pullback prediction.

The EA only trades buy positions and does not use Sl and TP.

The indicator draws an arbitrary second timeframe on the chart.

This code does not trace the iatr() because the iatr() or this code is a more modern version. This code uses original smoothing, a kind of SMA and not wilder smoothing. The analysis of the two smoothings can suggest opportunities elsewhere

This library simulates prop trading firm scenarios by resetting the account balance based on configurable profit and loss thresholds during backtesting, and logs reset results for analysis.

Translate risk percentages to the monetary figure based on the account balance

This MQL5 script exports candlestick data for various timeframes into a CSV file, capturing essential market information like open, high, low, and close prices. It analyzes each candlestick's characteristics, including body and wick sizes, while calculating additional metrics such as candle gaps. After processing the latest 21 bars, it notifies the user upon successful data export.

Marking the extreme highs and lows (OHLC) together with the extreme bid and ask prices

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.

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

Keltner Channel (MetaTrader indicator) — is a classical technical analysis indicator developed by Chester W. Keltner in 1960. The indicator is somewhat similar to the Bollinger Bands and Envelopes. It uses three plot lines: the middle line is the 10-day simple moving average applied to the typical price ((high + low + close) / 3), the upper and the lower bands are produced by adding and subtracting the moving average of the daily price range (High and Low difference) from the middle line. This way, a volatility-based channel is built. In this version of the indicator you can modify all the parameters of the MA. The indicator is available both for MT4 and MT5 versions of the platform.

Logger with the ability to log individual modules or code sections

Simple Expert Advisor with custom R-squared optimisation function

Dynamic VWAP level which can be averaged over multiple days

1234567891011...199