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

MQL5 Source Codes of Expert Advisors for MetaTrader 5

icon

Expert Advisors analyze price charts and trade automatically following underlying rules. Here you can find MQL5 source codes solving a variety of problems. You are able to select both simple Expert Advisors based on moving average crossing and complex ones involving complicated signal generation algorithms and protection against trading mistakes.

You can download and launch offered Expert Advisors in MetaTrader 5. It is recommended that you test and optimize trading robots in the Strategy Tester before using them. The library of Expert Advisors is also available directly from MetaTrader 5 platform and MetaEditor development environment.

Submit your code

Good afternoon guys, I'm a new student on metatrader5, I'm creating a robot to copy trades from a demo account and save them in a database I'd like some help identifying possible problems, best solutions for the code, etc.

A lightweight tool for manual scalping in MT5 using keyboard shortcuts

TardioBot V1.05, named after of a historical figure Giuseppe Tardio, is an Expert Advisor designed for MetaTrader 5 that employs a triangular arbitrage strategy.

Expert Advisor for MetaTrader 5 that combines Exponential Moving Averages (EMA) and Relative Strength Index (RSI) to generate trading signals. Includes risk management features and trading time filter.

The Cincin EA (v2.24) is an automated trading system for MetaTrader 5 that executes conservative random trades on a specified symbol (e.g., EURUSD), with features like basket management, hedging, and position control.

EA Spread lister shows the current, min and max values for all symbols / instruments.

The EA identifies trade setups by waiting for a user-defined number of indicators (e.g., 2 out of 3) to show divergence simultaneously. This multi-layer confirmation approach filters out market noise. Key Features: Triple Confirmation Engine: Analyzes RSI, MACD, & Stochastic divergence. Advanced Filters: Optional Trend Filter (MA) and Volume Filter for superior signal quality. Full Customization: Control all indicator settings, divergence sensitivity, and trade logic. Professional Risk Management: Use fixed lots or percentage-based money management with SL/TP.

Tarantella EA: Advanced grid trading system with hedging capabilities and Market Profile integration. Uses ADX trend filtering, Fibonacci-based grid spacing, and multi-layered entry conditions (RSI/ATR/volume) to execute trades only within Market Profile value areas. Features intelligent risk management including trailing stops, breakeven triggers, and partial hedge closing.

BotCilento is a sophisticated grid-trading Expert Advisor for MetaTrader 5 that combines trend-following signals with adaptive risk management.

Breakout Trader 1.0 trades breakouts from the range.

This expert is a system to help any trader to make a grid of orders.

An automated Expert Advisor that implements a popular MACD-based strategy as seen in a viral YouTube video with over 3.5 million views. Combines MACD crossovers, trend filtering with the 200 MA, and support/resistance detection.

Name of expert is 'MultiStrategyEA'

The Pending_tread EA is a versatile and easy-to-use trading robot designed to automate the placement and management of multiple pending orders arranged in a grid pattern above and below the current market price. This EA is well-suited for scalping strategies and can operate on any timeframe or currency pair, making it highly flexible for various trading styles.

Set Auto TP and SL: The “Set Auto TP and SL” (Take Profit and Stop Loss) feature is a crucial tool in any trading strategy, designed to automate risk and reward management. It allows traders to define fixed price levels where a trade should be automatically closed to either secure profits (TP) or limit losses (SL), removing the need for constant manual monitoring. When this feature is enabled, each position you open will automatically include a predefined Take Profit and Stop Loss level based on your custom parameters, such as a specific number of pips, percentage of balance, or technical levels. This not only saves time but also ensures that your trades are protected from sudden market movements and emotional decision-making.

The RiskManagement library in MQL5 provides efficient and dynamic risk management, optimised to minimise resources. It allows setting maximum profit and loss limits with customisable modifiers. It includes OCO order control and tools for candlestick management and price conversions.

CryptoTrend 1.00 Expert Advisor is an automated trading system designed for trading cryptocurrency (in particular, BTC). Main features: Bollinger indicator: Used to identify market extremes and generate buy and sell signals. Order Block filtering: Allows to find support and resistance levels, which helps to reduce the number of false signals. Self-learning: The entry threshold is adapted depending on the statistics of winning and losing trades, which allows the Expert Advisor to adapt to changing market conditions. Risk management: Calculates stop loss (SL) and take profit (TP) levels based on risk analysis and correlation

A Simple RSI and Moving Average-Based Expert Advisor for MQL5

EXSR.mq5: A counter‑trend MT5 EA that catches reversals by combining RSI(14) extremes with Bollinger Band breakouts and a reversal candlestick, placing one trade per symbol with fixed SL/TP.

Trading Gap Weekend, is it profitable?

Good afternoon everyone) First time posting my code!!!

This Expert Advisor (EA) implements a triangular arbitrage strategy between three currency pairs: EURUSD, USDJPY and EURJPY

This EA is meant to impose a few rules to manage baskets.

Butterfly Strategy Expert Advisor This Expert Advisor (EA) implements the Butterfly harmonic trading pattern across multiple timeframes (M2 to D1) for automated forex trading. It detects bullish and bearish Butterfly patterns using pivot points and executes trades with customizable risk management and multiple take-profit levels.

Simple Expert Advisor with custom R-squared optimisation function

The AutoCloseOnProfitLoss Expert Advisor (EA) is a powerful automation tool for MetaTrader 5, designed to close all open positions when predefined profit or loss targets are reached

This Expert Advisor (EA) helps traders manage risk by automatically adjusting position sizes and stop-loss levels based on market volatility, using the Average True Range (ATR) indicator. The EA calculates the optimal position size for each trade according to a user-defined risk percentage and the current ATR value, ensuring consistent risk exposure across all market conditions. It also offers an ATR-based stop-loss option to adapt to volatility, while employing a simple moving average crossover strategy to open buy trades. Ideal for traders seeking to automate risk management without complex trading logic, this EA prioritizes account protection and simplifies the trading process.

The EA opens positions randomly (50/50 chance for Buy or Sell) when no position is open.

Takes trades based on ICT silverbullet and 2022 model with trailing stops and partials, also keeps entry according to OTE, and risk minimal. It works in a small time window of silver bullet especially NY session, and if no trade found, 2022 model and fibonacci OTE jumps in to get a trade. But entry is so only after confirmation with these models being there, hence trades will be less for minimal drawdown and high winrate. To know more about these strategies, you may visit Inner Circle Trader YouTube channel.

My first code on the site, which requires improvement. The idea to create an ideal tool for traders, in the work on the main component of any trading system-Risk Manager

This is a simple mean reversion EA

Strategy based on the standard indicator iCHO (Chaikin Oscillator, CHO) and custom indicator 'CCIDualOnMA'

Panel based on CDialog class. Work on the current symbol. Deleting, setting Take Profit, setting Breakeven on a group of positions

Trading system by iMA indicator (Moving Average, MA). Development of MA Trend.

Algorithm cycle: when there are no open positions, open two opposite positions. Wait for both positions to close.

This Bot detects the open of a new candle on any set timeframe, thereby making it easier to run a one-time code, place trades and call other functions. The code is written in the OnTick() function.

Detecting the start of a new bar or candle in an Expert Advisor's OnTick() event handler.

This MT5 Expert Advisor combines multi-timeframe candlestick pattern analysis with fundamental event filtering to execute trades with disciplined risk management.

This is a piece of code to add to an existing Expert advisor to track withdrawals from your account where the EA is running. It helps the user to monitor his or her withdrawals from a particular account.

The EA automatically trades based on trend and mean reversion signals with validated parameters.

12345678910111213141516171819202122232425262728293031323334353637