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

Mirrors trades opened, modified, and closed by another EA on the same hedging account, selected by magic number. By default it inverts direction (Buy↔Sell, SL↔TP), so you can forward-test the reverse of a strategy with real spreads, slippage, and execution.

A free open-source MT5 utility for analyzing historical trading performance beyond Profit Factor.

Shows where stops are likely resting and which ones were just taken. Liquidity pools = confirmed swing highs and lows that price has not traded through yet, equal highs/lows (a bigger pool) and yesterday's high and low. When a bar trades beyond a pool it is marked as swept, and as "grabbed & rejected" if the same bar closes back inside. Non-repainting: a swing is used only after N closed bars on each side. The panel is a neon city drawn on a CCanvas: the price is a flying car, sell stops are towers below it, buy stops floating platforms above it, yesterday's levels golden billboards, a searchlight sweeps the sky and a ticker runs today's catch. Two buffers give the nearest active pool above and below for use in an Expert Advisor. Indicator only: it never trades.

Measures whether an indicator repaints instead of trusting the claim. It re-reads the buffers of any custom indicator on bars that have already closed and counts every value that changes, appears or disappears, with the furthest shift back at which that still happens. Verdict per buffer on a chart panel, every event written to CSV.

Tests whether live closing deals still match the backtest of an Expert Advisor. A bootstrap-calibrated CUSUM detector raises an alarm and estimates when the drift began, a two-window check separates a short dip from a lasting decline, and an expectancy decomposition shows whether the win rate or the trade sizes changed. The script generates demonstration data on the first run and is written in pure MQL5.

A free, fully open EA: buy GBPJPY every Monday at 11:00 server time (04:00 New York), close at 23:00. Stays profitable in backtest with the entry anywhere from 09:00 to 13:00. Attach to GBPJPY M1.

Quickly view each and every individual market's open and close times. Very important for short term scalping. I own the copyright, if anyone modifies or uses this it must stay free. Comments and feedback welcome.

Shows the real spread for each server hour, measured from your broker's own tick history: median and 90th percentile per hour, optional cost as a share of your stop and per lot, and CSV export.

A chart panel that shows the contract specification details that decide position size and trading cost (point value, spread cost, margin, swap, execution rules) in the account currency, warns about broker settings that silently break lot-size code, and exports the audit of every Market Watch symbol to CSV.

H1 indicator that combines support/resistance confluence from H4, D1 and W1 with EMA trend alignment and candlestick confirmation. Shows non-repainting BUY/SELL arrows with ATR-based stop and reward/risk filtering.

Script that lists the global variables of the terminal with value, last access time and age, filtered by prefix, substring and age. It exports them to CSV, deletes the matching ones after a confirmation and a backup, and restores them from a CSV file.

Tracks changes to 18 broker contract properties against a saved baseline, with before and after values, a chart panel and a local CSV audit trail.

The Adaptive Kalman Trend Filter smooths price fluctuations to highlight the underlying market trend, adapting its responsiveness as market conditions change.

Open-source EURUSD Expert Advisor for MetaTrader 5 Strategy Tester, based on RSI exhaustion signals, ATR-based exits and volatility-adjusted spread filtering.

ZoneUS30 is a simple US30 Expert Advisor focused on SELL opportunities after upward price extensions. The strategy combines a mean-reversion concept with a carry-trade idea: when short positions receive positive overnight swap, the EA can benefit both from a price correction and from holding the position over time. Designed for US30 and intended for experimental and educational use. Counter-trend trading involves significant risk, especially with high lot sizes.

iFVG Indicator With Signals

Trend-following Expert Advisor for MetaTrader 5 combining Supertrend direction with ADX and DI confirmation. Uses an ATR-based stop loss and risks up to 0.5% of equity per trade.

Marks impulse candles: body at least ATR x multiplier, body at least a set share of the candle range, close near the extreme, optional tick volume confirmation. Green arrow below a bullish impulse, red above a bearish one. Closed bars only, no repainting. Signals are in the two buffers so an Expert Advisor can read them with iCustom.

Account level risk guard for prop firm accounts. One copy on any chart watches every position on the account, closes everything when the daily loss or maximum loss limit is hit, caps lot size and can flatten around high impact news. Logs every action to the Experts tab and a CSV.

Draggable on-chart manual trading panel with multi-timeframe bias, ATR SL/TP hints, a trailing stop and one-click BUY/SELL/CLOSE ALL.

Open-source MT5 indicator for confirmed market structure, volumetric order blocks and estimated buy/sell activity.

Marks swing highs and lows only after N closed bars have confirmed them, so a drawn swing never moves or disappears.

Turtle-style Donchian breakouts on gold, followed with three exits at once: an ATR trailing stop, the Turtle exit channel and a fixed target. Backtested on XAUUSD H1 and H4 in 2025 and 2026, where all twelve combinations were profitable. Non-repainting, with buffers for an Expert Advisor.

A Turtle-style breakout EA for gold. It buys when an H4 bar closes above the 20-bar high in an uptrend, with a 2 ATR stop and a 2R target. Backtested on XAUUSD from January 2020 to September 2026: +9,029.72 on 10,000 at 1% risk, profit factor 1.77, max drawdown 11.38%, 6 of 7 years profitable.

Finds the weekend CME gap on gold and on 24/7 Bitcoin charts, keeps every unfilled gap on the chart until price returns to it, and shows how often gaps filled, how fast, how far price ran first, and what fading them would have made. Non-repainting, with buffers for an Expert Advisor.

Posts your MT5 opens and closes to a Telegram chat: side, symbol, entry, stop and target in pips, lots, and on close the result, pips, R-multiple and time held. Retry queue, restart-safe, never trades. Free Telegram and Discord trade notifier for MT5

MQL5 port of a Pine Script ATR trailing-stop indicator: nLoss = ATR-multiple, the stop ratchets under price in an uptrend and over price in a downtrend, and flips (with a buy/sell arrow) when price closes through it. Includes a Python reference port and a parity test that checks both agree with a literal, bar-by-bar transcription of the Pine semantics (na/nz/series history).

A small demo Expert Advisor: EMA fast/slow cross entries (evaluated on closed bars only, no repainting), ATR-based stop-loss and take-profit, spread filter, and position handling that works on both hedging and netting accounts. Includes a Python reference implementation for parity testing. This is a deliverable example, not a trading recommendation - the attached equity curve is from synthetic data and shows the method, not an edge.

Time weighted average price of the running session, anchored at the cash open of Frankfurt, London, New York or Tokyo with automatic daylight saving. Every second counts the same, minutes without a tick carry the last price, and two bands show the time weighted standard deviation around the line.

Panel that samples the spread once per second and shows it in points and in the symbol's natural unit (pips on FX, index points on index CFDs), with rolling min/avg/median/max, a session statistic since server midnight, the spread as percent of ATR, a hold-time alert and an optional CSV log. It never sends an order.

Marks the Asian session range, signals when London or New York sweeps one side of it and reverses, and keeps a scorecard of how every past signal ended in R, spread included. Non-repainting, with buffers ready for an Expert Advisor.

An intraday Smart Money Concepts EA for gold. It waits for price to sweep a recent swing high or low, confirms the reversal with a close through the sweep candle's body, and trades only with the H1 trend. Backtested on XAUUSD M15 over 2025 and 2026 at 1% risk per trade.

Free risk-based position size calculator built specifically for Gold (XAUUSD). Enter your account balance, risk percentage, entry price and stop-loss price - the indicator calculates the exact lot size, risk amount, stop distance, risk/reward ratio and potential profit, and draws entry, stop and take-profit lines on the chart. Contract size is read automatically from the symbol specification, so it works on any gold symbol without manual setup.

Hull Moving Average indicator displaying four periods on a single chart, colour-coded by direction (green for rising, red for falling, grey for flat). Implemented with a ring buffer and incremental running-sum math, so memory and CPU use remain constant regardless of chart history length. Buffer layout is documented and stable, making the indicator suitable for use with iCustom() from EAs. Supports 2, 3, or 4 Hull lines depending on configuration.

Protect Your Funded Account with Institutional-Grade Risk Monitoring. The #1 reason traders fail prop firm challenges is not a bad strategy; it is breaching daily drawdown limits. The AlphaQuant Prop Firm Daily Drawdown Dashboard is a free, high-visibility Expert Advisor

A real economic-calendar news filter that also works in backtests. Export the events once with a script, then block new entries around news both live and in the Strategy Tester. Fixes the one-hour DST shift of historical calendar times.

Educational MT5 hedging-account trade panel with risk sizing, spread protection, a persistent daily-loss lock, break-even and trailing stops.

TREND Follower (Daily) is a lightweight, development-oriented Expert Advisor (EA) created as a base trading architecture for research, learning, experimentation, and further development. The EA is intentionally designed around a simple concept: follow the market direction using the relationship between price and the Parabolic SAR. It is not presented as a fully optimized or finished trading system. Instead, it provides a clean and accessible foundation that developers can study, modify, test, and expand.

Account-wide MT5 risk protection EA for prop-firm and personal accounts. Monitors daily and overall drawdown, position losses, safety buffers, and automatically protects the account when configured limits are reached.

Spread histogram in a sub-window with current/avg/max/min stats, cost per trade, and threshold alerts for scalpers.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207