Watch how to download trading robots for free
Find us on Telegram!
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 Code Library for MetaTrader 5 - 2

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

It is taken into account that there are 30 days in a month, 365 days in a year The script demonstrates the counter of time until the beginning of the new year

The ADX (Average Directional Index) Smoothed indicator enhances the standard ADX by applying dual exponential smoothing filters to reduce noise and provide clearer trend signals. It plots three lines: smoothed +DI (blue), -DI (red), and the main ADX line (green). This refined version helps traders identify trend strength and potential direction changes with reduced false signals. The indicator excels at confirming established trends and warning of weakening momentum before actual price reversals occur, making it valuable for both trend following strategies and determining optimal entry/exit points.

The RSI Expert Advisor (EA) is an automated trading tool developed for the MetaTrader 5 (MT5) platform. This EA leverages the Relative Strength Index (RSI) to identify buy and sell signals, incorporating risk management, partial position closing, and trading hour restrictions to optimize trading performance.

Custom MACD for MetaTrader 5 enhances the classic MACD with real-time signal alerts sent to your phone. Detect trends and reversals with customizable parameters, intuitive visuals, and automated buy/sell notifications.

All indicators required by BBMA Strategy in a single indicator.

This indicator for Breakout Strategy. It doesn't print objects on the chart.

Dynamic VWAP level which can be averaged over multiple days

Trading XAUUSD (Gold) is often influenced by major economic news events like USD, GBP, or EUR releases. To mitigate risks during these volatile periods, using a News Filter in your Expert Advisor (EA) is essential. In this article, I’ll share how to create a simple News Filter on MT5 and apply it to XAUUSD trading.

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.

A simple and effective Expert Advisor based on Stochastic Oscillator reversal signals on the H1 timeframe. Buy signals are triggered when %K crosses above %D below the 20 level. Sell signals are triggered when %K crosses below %D above the 80 level. Risk is calculated based on the account balance, with the lot size set to 0.1 (adjustable as needed). Take Profit (TP) is set to 300 points for all positions. Stop Loss (SL) is dynamically calculated based on the opposite crossover signal. The position is closed when a crossover in the opposite direction occurs, as well as when TP or SL is reached

This indicator calls 3 other subwindow indicators. All files go in your Indicators folder.

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

This Indicator shows Buy or Sell Signal

The Custom MA Cross with RSI Indicator for MT5 is a versatile trading tool designed to help traders identify trend changes and filter entries using momentum. This indicator combines two moving averages (MA) with the Relative Strength Index (RSI), offering clear buy and sell signals.

This indicator will shows the time remaining until the end of the candle. You can choose colour and the font size.

A moving average of pure tick volume with histogram bars tracking bullish/bearish candle color

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.

Countdown is an advanced indicator designed for traders who want to track the time remaining until the next candlestick or the next market open clearly and efficiently. With three flexible display modes (commentary, chart borders or next to price), this indicator offers a customisable solution to suit your trading needs.

MACD Divergence indicator

Two Symbol Spread Indicator

Indicator for calculating the average price of open positions, you can use the magic number if you want to separate the positions of just one robot, but the zero number is for manual operations.

Better Volume is an advanced indicator designed to analyse the behaviour of volume on price charts. It combines volume information with metrics such as candlestick range and moving averages to identify important patterns in the market, such as buy/sell climaxes, churn and weak candles. With its dynamic visual interface and volume categorisation, the indicator offers valuable insights for traders who want to make informed decisions based on volume flow.

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 CalculateHistoryProfit script version 1.0 is designed to calculate profit for a specified period using a chart panel.

Volatility Stop - indicator of stop levels by volatility

Ergodic oscillator Stochastic Momentum Index (SMI)

The "Net Volume" indicator shows the volume taking into account the pressure of sellers and buyers

Know Sure Thing (KST) oscillator indicator based on the rate of price change (ROC)

Correlation Coefficient" indicator

Chaykin Money Flow (CMF)" indicator

The XMA_Ishimoku indicator with additional trend strength indication using colored dots based on the standard deviation algorithm. The original code in the attached link had plotting problems.

A volume oscillator is a useful technical analysis indicator that predicts the strength or weakness of price trends

EquiPeak Drawdown Tracker is an indicator designed to monitor and record the maximum drawdown of your trading account in real time. It's not just a current drawdown indicator; it's especially useful for visually comparing your current drawdown with the maximum historical drawdown you expect or have previously recorded.

Kuskus Starlight is an oscillator that utilizes a Fisher price transformation to identify trends and potential reversals. The original MT4 code by Scriptor is available at: https://www.mql5.com/en/code/8365.

Candle Signature with Example | For Research and Development

This is a simple mean reversion EA

A logger with the ability to log specific modules or code sections

Chande Kroll Stop indicator - stop levels for short and long positions.

changing character prices on an interval

The indicator draws an arbitrary second timeframe on the chart.

123456789...189