MQL5 Source Code Library for MetaTrader 5 - 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

Account-wide protection for prop firm and funded accounts: enforces a daily loss limit and a maximum overall loss (FTMO-style), closes all positions and blocks new trades when a limit is hit, with an optional profit target.

Unbroken swing highs and lows, shaded by strength: how old each level is and how many times price was turned away from it.

A panel showing the current spread, the average spread since the indicator was attached and the spread cost of a 1-lot trade in account currency.

Draws the Tokyo, London and New York trading sessions as coloured boxes that span the high and low of each session.

A panel that ranks the eight major currencies (USD, EUR, GBP, JPY, AUD, NZD, CAD, CHF) by their average rate of change against each other.

Splits the current swing range (last swing high to last swing low) into a Premium zone above 50% and a Discount zone below 50%, with an equilibrium line and a live label that shows where the price is inside the range.

Detects swing highs and lows and labels every break of market structure: BOS (Break of Structure) when the trend continues and CHoCH (Change of Character) when the trend reverses.

Detects bullish and bearish Fair Value Gaps (three-candle price imbalances), draws them as boxes extending to the right and automatically removes each box once the price fills the gap.

Marks bullish and bearish order blocks (the last opposite candle before a strong impulse) and tracks their state: fresh, mitigated when price returns, and removed when broken.

Fair Value Gap (FVG) Detector with Auto-Removal When Filled

Shows the daily opening gaps for stock indices and indicates whether each one has been filled.

Marks built-in economic calendar events on the chart with time lines, optional windows, labels, a panel and alerts.

A compact dashboard that classifies EMA trends across multiple timeframes and displays slope, ATR distance, duration and an alignment summary.

Draws support and resistance levels from confirmed swing highs and lows, and the fair value gaps (3-candle gaps) that price has not filled yet. Rule-based, merges nearby levels by ATR, removes a gap as soon as price trades back through it.

Classic 50/200-day Golden Cross trend filter: long while the fast SMA of daily closes is above the slow SMA, flat (or optionally short) otherwise. One decision per completed D1 bar, sizing by % of balance or fixed lot.

A live account-level readout — equity, balance, tracked peak, and current drawdown % from that peak — the one risk number most charts never show you.

Live spread stats plus real fill-vs-requested slippage logging, account-wide — because "my broker widens spreads at news time" and "my fills are always bad" deserve numbers, not a feeling.

Closed-bar sweeps of confirmed swing levels, with wick, volatility and freshness filters, liquidity lines, a dashboard and optional alerts.

Trade manager for MT5: break-even, stepped trailing stop and progressive profit lock. Works with manual trades or any EA. Distances in ATR, so it fits any symbol. Bilingual panel (EN/AR).

Draws the daily open price as a horizontal line and shows, in points, how far the current price is from today's open. The label changes color depending on whether the price is above or below the open.

Supertrend trend-following indicator based on ATR. The line changes color and side of the price when the trend changes, with optional signal arrows and alerts.

Shows the time left until the current candle closes and the current spread in a corner of the chart. The countdown updates every second, even when no new ticks arrive.

Dynamic support and resistance bands built from a moving average and the Average True Range (ATR). The bands widen when volatility rises and narrow when it falls.

Supertrend expert advisor for MT5 on Gold (XAUUSD), forex and indices: entry on the closed candle of the flip, stop at the Supertrend line, target by stop multiple, breakeven and lot by risk percent. Open source code.

Daily pivot point with three resistance levels and three support levels, using Classic, Fibonacci or Camarilla formulas.

Script that exports the closed trades of your account to a CSV file and prints a short summary: trades, win rate, net result and profit factor.

An account-wide MetaTrader 5 utility that tracks daily loss from the chosen start-of-day equity and intraday equity peak. Shows warning and critical levels with optional money and percent limits plus terminal, sound or push alerts. It never places, modifies or closes trades.

Draw Asian, London and New York session ranges as chart boxes with high/low lines, labels and an optional London–New York overlap. Configure GMT or broker-server hours and review the latest session statistics in a panel.

A small script that turns "risk in % of the account" and "stop loss in pips" into a lot size. It only calculates and prints; it never opens, modifies or closes trades.

Session windows are quoted in GMT; the chart runs on the broker's clock. This indicator takes each window in GMT, applies your broker's offset, and draws the box over that window's bars. It adds the high and low lines to every enabled window unless you switch them off, prints the session name and range only on that session's newest box when there is room, and never trades.

Chart panel that calculates position size from risk % and stop-loss in points, with tick value, margin and money at risk. Does not place orders.

Marks previous day, Asian and London session highs and lows from chart bars and flags closed-bar, ATR-filtered liquidity sweeps. Non-repainting, with EA-readable buy/sell buffers and an on-chart display panel.

Auto-scaled round-number grid for any symbol — big figures and half levels drawn to the right spacing whether you're on EURUSD, USDJPY, XAUUSD or an index, plus a live "distance to nearest magnet" readout.

Compact zero-buffer MetaTrader 5 on-chart HUD displaying live Spread in points and pips, Daily ATR(14) range consumption percentage, broker Stops/Freeze levels, and 1R lot size.

Shows the risk every past trade really took (the loss at its stop loss as a % of the balance at entry) and how far a fixed lot drifted from the tested risk. Read-only.

Draws the previous day High, Low and Close as horizontal levels on the chart, with optional history for several past days, extension of today's levels to the right and price labels.

TradingView-style Long/Short position tool for MT5: drag the Entry, Stop and Target lines and get lot size, risk, reward, R:R and margin instantly.

MA Toolkit: a compact moving average indicator written from scratch. Choose SMA, EMA or LWMA for a fast and a slow line, see the fast line colored by its slope, and get optional crossover arrows, alerts and an info panel.

Horizontal lines at round figures around the displayed price, with a spacing that adjusts according to the zoom level.

A basic expert advisor that trades in the direction of the 9.30 am New York 5-minute candle on index CFDs (US100 / NAS100). One trade per day, fixed stop-loss and take-profit levels, forced closure; no martingale or grid strategy.

123456789101112...219