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

Persistent MQL5 outbox with a Telegram demo and offline tests. An uncertain result is never retried automatically. Manual retry may duplicate a message; SENT means API acceptance, not a read receipt.

Lot size calculator panel for MT5 on Gold (XAUUSD), forex and indices: risk in percent of balance, percent of equity or money, stop in points, exact loss per lot, one click Buy or Sell with stop and target. Open source code.

Liquidity indicator for MT5 on Gold (XAUUSD), forex and indices: equal highs and equal lows from swings, marked as swept when a wick runs the level and the candle closes back. Open source code.

Fair value gap (FVG) indicator for MT5 on Gold (XAUUSD), forex and indices: three candle gaps on closed bars, ATR size filter, the open part shrinks as price fills it, mitigation by touch, midline or full fill. Open source code.

Структура M5 как при ручной разметке: развороты берутся по фракталам H1, точки ставятся на настоящие экстремумы свечей M5. Волна никогда не проходит мимо экстремума, подтверждённые точки не перерисовываются.

This is an indicator that identifies Wolfe waves and plots them

Previous day high and low, previous week high and low and today's open as horizontal lines with small price labels, on any timeframe.

Draws the Tokyo, London and New York sessions of the last few days as boxes from each session's high to its low, with the high and low printed on the chart. Session hours are set in server time.

Countdown to the close of the current bar, the live spread in points and the time left until the next server midnight, when brokers roll positions over and charge swap.

Shows the spread of every bar as a histogram with its average, flags unusually wide spreads, and lists the live spread, swap long/short, the triple-swap day and a bar countdown.

Plans ATR-based stop loss and take profit levels for a buy and a sell from the current price and works out the lot size for the account risk you choose.

A compact dashboard that shows the EMA trend direction and ADX strength of several symbols across several timeframes at once.

Asian, London and New York session boxes with high/low range, plus a clean panel showing ADR, today's % of ADR, spread and time to candle close.

Watches a basket of positions (whole account, one symbol and/or one magic number) and closes all of them together when the floating P/L hits your profit target, loss limit, trailing profit lock or a set time. Does not trade.

Institutional on-chart account inspector, behavioral signature analyzer, EA vs manual breakdown, and prop firm drawdown auditor with 1-click HUD.

G7 FVG OB Confluence AutoTrader is a professional Smart Money Concepts (SMC) Expert Advisor and on-chart analysis utility for MetaTrader 5. Engineered for Gold (XAUUSD), Forex, and Indices, it detects high-probability institutional setups where M15 Order Blocks (OB) and Fair Value Gaps (FVG) physically overlap. KEY CAPABILITIES: • Dual-Engine SMC Detection: Scans real-time 3-bar Fair Value Gaps and institutional impulse displacement Order Blocks. • Precision Confluence Matching: Filters out low-quality zones by requiring exact physical confluence between OB and FVG before triggering entries. • 6-Card AI Confidence Radar: Evaluates NY Zone Macro News, USD (DXY) correlation, liquidity sweeps, and confluence score (0-100%). • Interactive On-Chart Trader HUD: Adjust lot size, Stop Loss, and Take Profit directly on the chart without opening EA properties. • Prop Firm Guard: Built-in daily loss circuit breaker (-4.0%) and target lock to protect funded accounts.

A premium, on-chart analytical dashboard that automatically scans for ICT Order Blocks, Fair Value Gaps (FVG), and calculates real-time AI confluence scores for Smart Money traders.

G7 Pro Trade Manager & Prop Firm Equity Protector is a professional on-chart trading assistant for manual traders and prop firm accounts (FTMO, FundedNext, The5ers). It features a clean obsidian HUD dashboard directly on the MT5 chart with 1-click execution, automated breakeven shield, dynamic trailing stop, and a daily loss circuit breaker to protect your funded account. Compatible with all pairs and accounts.

Order block indicator for MT5 on Gold (XAUUSD), forex and indices: the last opposite candle before a move that breaks a swing becomes a zone, fresh, tested and broken states, closed bars only. Open source code.

Tracks live midnight rollover spread spikes against a self-calibrating daytime baseline and outputs a binary iCustom guard flag (Buffer 0) so EAs can pause entries during liquidity drains.

When I first started scalping, I had a problem: during periods of high volatility, it sometimes took too long to calculate exactly 1%, and I’d end up setting an incorrect stop-loss or using a position size that was too low or too high. But with this calculator, I can do it much faster—I just have to drag a line to the stop-loss zone, and it automatically calculates the position size I should use for my 1%. I hope you find it very useful!

Moving average crossover EA for Gold (XAUUSD), forex and any symbol: one position per cross of two moving averages on the closed bar, exit on the opposite cross, stop loss, take profit and breakeven in points. Open source code.

Auto Fibonacci retracement for Gold (XAUUSD), forex and any symbol: draws the levels on the last completed swing leg by itself, with the 61.8 in its own colour, prices on each level and an optional alert. Open source code.

Forex session boxes for Gold (XAUUSD), forex and any symbol: draws the Asian, London and New York sessions with their high and low extended to the right and the range in points, in your broker server time. Open source code.

An all-in-one Smart Money Concepts (SMC) indicator that automatically identifies Swing & Internal Market Structure (BOS/CHoCH), Order Blocks, Premium/Discount zones, and Equal Highs/Lows. It features a real-time multi-timeframe bias dashboard to help traders make informed decisions.

A free MT5 script to calculate position size, risk amount, and risk-to-reward ratio visually on the chart.

On a linear MT5 chart, a trend that grows or falls by a steady percentage is a curve, and a straight channel misses it. This indicator draws the real exponential curve, fitted on closed bars to the cleanest of 19 look-back windows, with deviation zones, a projection ahead and a card with the fit, the trend pace and the price position.

Real-time tick spread monitor that plots Maximum and Average spread curves per bar with points/pips display and local CSV persistence.

Lightweight Expert Advisor combining Scalp & Swing logic with an "Always-ON" position-securing layer. Includes a fully interactive on-chart panel with manual trade buttons, risk- based lot sizing, partial close, break-even, trailing stop, swing SL/TP switching, and a one-click "Secure All" tool.

Countdown to the next high-impact news from the MT5 economic calendar, with a red NEWS WINDOW warning for prop-firm news rules. Display and alerts only - it never trades.

Drag the MetaTrader 5 chart freely in any direction and stretch the price and time scales with the mouse, the way TradingView does it. One click on ON/OFF returns the normal chart. A small indicator that draws nothing, never trades and works next to any Expert Advisor.

Plots the range of the Asian session and marks breakouts during the London session with arrows, stop and target levels, and alerts

Tick Scalper Helper is a manual trading utility for traders who work on very short time frames and want to see every price change.

Draws the daily opening range and its breakout levels, with a dashboard showing how the range resolved over your lookback: broken up, down, both ways or not at all, and how often a breakout hit its target before the opposite side.

Prop Firm Guard Panel is an on-chart panel for prop firm challenges and funded accounts. It shows in real time the daily loss used and the room left, the max loss room and equity floor, and the progress toward the profit target. The start-of-day balance is rebuilt from today's closed deals, so the values stay correct after a restart. Colors change from green to orange to red as limits get closer, with optional popup and push alerts. Auto, dark or light theme. Display only: it never opens, modifies or closes trades.

Mouse Scroll Zoom in Zoom Out

Trending up, trending down or ranging: a verdict for every bar, and how long it has held. Each stretch of one regime is boxed on the price chart, ADX columns below show how strong it is, and a one-line panel gives the regime, its age and the ADX. Values for Expert Advisors and an alert on closed bars.

Reads your closed positions and the M1 bars after each exit. Shows how many stopped-out trades later reached their take profit, how far take-profit trades kept running and how much move was left after manual or EA exits. Summary panel, per-position log table and CSV.

Free educational EA — a single-position trend-following EMA crossover system for XAUUSD M30, released as open source for beginners to study trade ownership guards, preflight order validation, risk-based lot sizing, and server-time session filtering. This code demonstrates how a strategy - identifies and manages only its own positions and orders through MagicNumber and comment tags, - wraps CTrade with an OrderCheck preflight that blocks invalid or margin-breaking requests, - sizes each trade from a fixed stop-loss and risk percentage, - and restricts entries to a configurable broker session window with a daily close-all — all evaluated on completed bars only, so signals never repaint.

Non-repainting fair value gaps on closed bars, with zone states (active, touched, mitigated) and iCustom buffers for EAs.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213