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

Audits the tick history that 'Every tick based on real ticks' backtests replay. Five checks per symbol over the last N days: impossible and crossed quotes, timestamps that run backwards or repeat, one-tick price reversals sized in multiples of the symbol's own median spread, silences inside the broker's declared quote sessions, and minutes where the ticks and the M1 bars disagree. Every finding goes to CSV with its millisecond timestamp, and the tool prints its own arithmetic so the report can be recounted. Read only: no trade function, no DLL, no network.

A specified moment in time can be analyzed through multiple synced timeframes from 1 host chart for a symbol.

Opening Range Breakout EA template with built-in account protection. Marks the high and low of the first N minutes after the session open and places OCO stop orders above and below the range. Includes risk-based position sizing, daily loss limit, maximum drawdown limit, ATR range filter, trade direction filter, and protection against positions carried overnight. All session times are configurable inputs. Educational template, not a profit-guaranteed system. Test on demo before any live use.

Displays the symbol properties that cause the same EA to behave differently on a different broker: trading hours, contract size, tick value, spread statistics, swap cost and real-session coverage. Read-only; does not execute trades.

Exports closed trades to CSV with Maximum Adverse Excursion (MAE) and Maximum Favorable Excursion (MFE) in points and money, calculated from M1 history, plus the percentage of the available move each trade captured.

Opens charts for all Market Watch symbols or a custom symbol list in one click, on any timeframe, with an optional template applied to each chart. Skips charts that are already open and limits how many are opened at once.

Shades the chart background by volatility regime (Compression, Normal, Expansion) based on the percentile rank of the current ATR. Shows the current regime on the chart, alerts on regime changes and exposes buffers for Expert Advisors.

Shades the chart background by volatility regime (Compression, Normal, Expansion) based on the percentile rank of the current ATR. Shows the current regime on the chart, alerts on regime changes and exposes buffers for Expert Advisors.

Draws Asian, London and New York session range boxes and marks liquidity sweeps: a closed bar that wicks beyond a completed session's high or low and closes back inside. Non-repainting arrows, extended session levels, alerts and iCustom-ready buffers.

Writes a CSV journal of every trade with the exit reason, and a report that shows how far each trade ran, in R. It never trades.

ICT killzones for MetaTrader 5: Asia, London and New York sessions drawn in New York time with automatic daylight-saving conversion, session highs and lows carried forward until price takes them, previous day, week and month levels, opening prices and time markers. One file, no DLL.

Arixis Market Regime Map is a non-repainting MT5 indicator that classifies market conditions as Trend Up, Trend Down, Range or Transition using price efficiency, normalized slope, volatility, market structure and multi-horizon agreement.

Resamples your closed trades 10,000 times to show whether your average trade is an edge or could still be luck: the 95% range of the average and the chance it is below zero.

Shows the day's result against the daily and max loss limits of a prop firm account, with a warning alert, in a panel on the chart.

The Market Behavior Analyzer is a practical indicator designed to make market structure easier to read directly from the chart. It identifies significant swing points, classifies them as Higher Highs, Higher Lows, Lower Highs, and Lower Lows, and tracks the movement between them in pips. It also provides a Market Story panel and an interactive Swing Inspector for examining impulses, pullbacks, retracements, swing duration, and the developing market structure.

Audits the bar history your terminal actually holds, which is the history every backtest and every indicator reads. Six checks per symbol: impossible OHLC values, broken bar times, bars missing while the broker's own session table says it was quoting, empty and flat bars, bars that disagree with the broker's own M1 series, and spread sanity. The headline figure is session coverage, not a grid percentage that mostly measures how many weekends you audited. Every finding goes to CSV with its bar time, and the audited bars plus the session table can be dumped so the whole report can be recounted by something other than this tool.

Gold EA that trades both directions: when the stochastic signal line turns, it places a stop order at yesterday's high or low, filtered by a Bollinger band. Self-contained, no custom indicators. Backtest on XAUUSD H1, July 2021 to September 2026: +245% on a 1,000 USD deposit at a fixed 0.01 lot, 23.9% maximum equity drawdown.

Calculates position size and daily / max loss limits for prop firm accounts and shows them in a panel on the chart.

A port of the Olsen group's Alpha Engine: eight limit-order agents trade intrinsic-time directional changes on a hedging account. They add on overshoots and trim at a profit on reversals.

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 guard for prop firm accounts. Watches every position on the account, closes everything at the daily or maximum loss limit, caps the money at risk per position, closes trades left without a stop and can flatten around high impact news.

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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208