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

A lightweight chart overlay that paints a smooth “daylight” gradient across Pacific, Asia, London, and New York sessions—plus optional session separators, event labels, and “sunray” highlights for scheduled news. Includes UTC/Broker/PC time modes and a manual DST shift.

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.

The Playground EA series was created for experimentation with Fair Value Gaps (FVGs) and liquidity concepts

A compact on-chart dashboard that monitors live spread behavior, tracks rolling Min/Max/Avg, and warns on abnormal spread spikes (news, low liquidity, rollover) using adaptive or fixed thresholds with optional alerts.

Scan multiple symbols and timeframes for wick-based rejection candles and display the latest signals in a clean on-chart dashboard with strength scoring, signal age, optional markers, and alerts.

This EA is intended to test a popular trading strategy. My own backtest shows that this strategy does not work as it was intended

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.

Utility MT5 EA that sends BUY/SELL deal notifications to Telegram via Bot API (WebRequest)

The script provides a quick estimation of an exponent/power factor for transformation of variable-length price increments into uniform distibution, that makes them a "random walk". The estimated value characterizes current symbol as more profitable when using in a particular trading strategy.

This is a simple price channel indicator allowing user to customize period and line colours. Often used in channel break strategies.

This function gives me the shortened names of the timeframes Example: "M1" instead of "PERIOD_M1"

It's like a bird's-eye view for BBMA Oma Ally fans. ust drag it onto the chart and you'll get all the BBMA signals running on the chart.

Securing data transfer between client and Server could be a big challenge for you as MQL5 programmer. You may have experience in using built in MQL5 encryption systems like AES.AES can securely encrypt your data but on the other hand is not secure when it comes to sending the AES key through insecure channels. You can only rely on asymmetric encryption systems Like RSA in such cases. you keep the private key at your server side and only share the public key with your clients. Even more you can use hybrid RSA_AES approach to archive more performance

Multisymbol OnTick.

iMy

In the graphical representation, techanalysis represents the trend line to the right of the candles on the breakdown (in green). After the breakdown, the movement along the red line is assumed.

Fox Wave Clean - Professional Order Manager Professional EA for efficient trade management with one-click position control. Clean design, powerful functionality.

A simple indicator based on Bollinger Bands showing its narrowing and widening phases with red/green colours.

The indicator is written by request on the forum.

Structure of input parameters

The Expert Advisor works with pending orders Buy Stop and Sell Stop according to the time specified in its input parameters.

The simplest Expert Advisor that analyses the price movement on a given number of bars and opens a corresponding position.

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.

Overview Grid Master EA is an automated trading system that implements a bidirectional grid strategy. It places multiple pending orders above and below the current market price, capturing profits from market oscillations in both directions.

This Screener was created to simplify the process of finding assets trading at discounted prices. Initial usage may take slightly longer due to the data loading process for all selected instruments. The tool can scan all available broker assets or be limited to specific asset classes.

Compression of tick data for storage in a compact form up to 3.5 times more compact than .tcs MQ files. And for fast work with them, because reading 3 bytes takes less time than reading 60 bytes of MqlTick structure.

A JSON library that supports MQL4/MQL5

This function performs the main logic of opening a trade. It calculates the opening price, take profit levels and stop loss based on the symbol information and parameters provided by the user. Prepare a trade request (MqlTradeRequest) with the necessary information such as symbol, volume, order type, slippage, comment, magic number, etc. Call the OrderSend function to send the trade request and get the result. SetTypeFillingBySymbol function: determines the order fulfilment type (Fill or Cancel, Immediate or Cancel or Return) according to the symbol's fulfilment policy. GetMinTradeLevel function: calculates the minimum trade level based on the freeze level and stop level of the symbol. Adjusts the minimum level to ensure that it is within certain limits and returns the result.

combination of many familiar indicators for beginner traders

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

The indicator implements one of the non-linear smoothing algorithms

A professional visual indicator for the popular "One Candle" Daily Breakout strategy (0.9 SL / 1.25 TP). Automates the vector analysis for Gold (XAUUSD).

CDateTime milliseconds extension + datetime supervisory variable extension

Set three crosses and monitor the daily percentage performance starting from a given time (that can also be set).

Idea by Andrey F. Zelinsky, based on an indicator by William Blau

Records ticks in real ticks mode and reads them in maths mode calling your strategy with each tick.

Professional panel for closing positions with 6 smart filters. Close all, by type, by symbol, or by profit/loss. Real-time P&L display. Perfect for emergency exits and risk management. Includes safety confirmations.

The function calculates the lot size of an open position. The opening price of a deal, the price of stop loss level and the risk per deal in per cent of the deposit are passed as parameters

This indicator implements the "Quarters Theory" - a technical analysis concept that divides price movement into four quarters around a central base level. It's designed to work with multiple asset types (Forex, stocks, commodities, etc.) and provides visual quarter levels on the chart.

An example of adding buttons for your advisors. In this example, a button has been implemented to close all active positions for all instruments. In addition to the button event processing functionality, methods for closing positions relative to the symbol name and counting the number of positions relative to the symbol name are also implemented.

DeltaFusion Lite is the simplified version of the DeltaFusionPro indicator for MT4. It calculates and displays Cumulative Delta and Net Delta, giving traders a clear view of buying and selling pressure within each candle. By analyzing the distribution of volume between bid and ask, it helps identify market sentiment shifts, potential reversals, and various types of divergences between price and volume.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194