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 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

The book "Neural networks in algorithmic trading with MQL5" is a comprehensive guide, covering both the theoretical foundations of artificial intelligence and neural networks and practical aspects of their application in financial trading using the MQL5 programming language.

Now we will get the code with function and purpose as below: 1. How to call and using the bollinger band 2. How to call and using the volume tick 3. How to call and using the Moving average volume. 4. How to code using the Trailling & Check volume lot size

Short description.

KA-Gold Bot is an advanced trading advisor specifically designed for gold, utilizing the powerful combination of the Keltner channel strategy and two exponential moving averages (EMAs) - the 10-period EMA and the 200-period EMA. Principle of Operation: The 10-period EMA represents the average price cutting above/below the Keltner band, confirming an uptrend/downtrend. The price being above the 200-period EMA supports the uptrend/downtrend. This indicates that the uptrend/downtrend has been stronger than the previous 10 periods, considering the volatility over the last 50 periods. - Time frame: M15

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

Syncs all chart symbols to symbol of the chart the EA is attached to

This utility is simple example to add sound alert on connect / disconnect

The final seventh part of the book discusses the advanced capabilities of the MQL5 API, which will be useful when developing programs for MetaTrader 5. These include custom financial symbols, built-in economic calendar events, and general-purpose technologies such as networking, databases, and cryptography.

In Part 6 of the "MQL5 Programming for Traders", we will study a key component of the MQL5 language – trading automation. We will start with a description of the fundamental entities, such as financial instrument specifications and trading account settings. These are prerequisites for creating properly operating Expert Advisors.

In Part 5 of the book, we'll delve deeper into the APIs associated with algorithmic trading, including financial data analysis and processing, chart visualization, automation, and user interactions.

In the fourth part of the book, we will focus on mastering built-in functions (MQL5 API) and will gradually delve into specialized subsystems. Any MQL5 program can utilize a plethora of technologies and functionalities. Therefore, it makes sense to begin with the most simple and useful functions that can be utilized in most programs.

Part 3 "Object Oriented Programming in MQL5" offers an immersion into the world of object-oriented programming (OOP) in the MQL5 language. Software development often involves the complexity related to the management of multiple entities, requiring advanced technology to improve programming convenience, productivity, and quality.

Part 2 "MQL5 programming fundamentals" is an introduction to the key concepts of this programming language. This part of the book is devoted to data types, identifiers, variables, expressions, and operators. You will learn how to combine different instructions to form the program logic.

The first chapter of the book introduces the MQL5 language and development environment. One of the new features introduced in the MQL5 language compared to MQL4 (MetaTrader 4 language) is support for object-oriented programming (OOP), which makes it similar to C++.

a Simple Visual Strategy Tester / Manual Trade Training using Martingale.

This Expert Advisor does not trade. A simple panel, implemented using the standard Canvas library, allows you to draw digits with the mouse. The trained mnist.onnx model is used to recognize the digits.

This is an mql5 Expert Advisor trading the breakouts and using Martin Gale risk management.

This function allows you to retrieve and return the filling policy of a symbol in MetaTrader 5. This is useful for making trading decisions based on the filling policy of a specific financial instrument.

"This advisor uses the RSI indicator to determine optimal entry and exit points in the market. A unique feature of the advisor is its martingale strategy, which allows for position reversal with an increased lot size during market reversals. The advisor offers flexible trading time settings: you can set a working time range and disable trading during specific hours to filter out news events."

The EA trades using the Rectangle, EMA and SMA indicators.

On contrast with Trailing Stop which a stop loss trails price until the price hits the stop loss and the position gets closed in profit, introducing Trailing Take Profit which take profit trails price when a position is in loss and ultimately the position gets closed with loss.

The AK-47 Scalper EA is fully automated. It employs a strategy of continuously entering Sell Stop orders and will modify them when the price moves against the pending orders.

Explore the implementation of equity-based position closure in your trading bot, where positions are closed automatically when the equity reaches a certain percentage threshold.

To use martingale money management when a position is in loss and price hits any of specific distances.

This code snippet implements a dynamic risk management strategy for existing trades. It focuses on closing trades based on profit or loss thresholds and employs a trailing stop loss to lock in profits as the trade moves favorably. The strategy helps manage risk and enhance profitability in a streamlined manner.

This MT5 Expert Advisor opens multiple buy and sell orders based on user input, featuring a simple interface with Buy and Sell buttons. The EA calculates lot size, checks the spread against slippage, and places orders accordingly. It is essential to test this EA in a demo account before using it in live trading.

This code initializes the necessary objects and input parameters, and defines a CheckTrades() function that calculates the risk and profit amounts based on the account balance and user input. It then iterates through open orders and checks if the current profit or loss meets the user-defined thresholds, and closes the position if necessary

This class allows you to create buttons on the chart as if they were chart objects(have time and price coordinates) these objects can be dragged on the chart and when scrolling they stay at the same place. If you wan't to learn some Object Oriented Programming or if you wan't to understand how chartevents work or you wan't to create graphical interfaces, you can learn a lot from this.

Close trades when the percentage profit or risk of the account is reached

to display trade history files(.csv) on charts.

MoveStoploss moves the stoploss as the trade move in your direction at a specific distance. Version 1.1 has automatic trail error fixed.

Returns the price for the most recent fractal high

Official example involve complex wrapper classes, Here is a simple one

This expert advisor is based on the alligator indicator and bollinger bands indicator. Currency pair: GBPAUD Time frame: 15min

Reversal strategy using Moving Average, Standard Deviation and RSI

US: This is a very simple code regarding an information panel. It doesn't use external files or anything like that! simply copy and paste it into your code the way the code was written. The dashboard displays; Active asset price Your position(Bought or sold) Maximum and minimum price of the asset Username open profit Balance PT-Br:Esse é um codigo bem simples a respeito de um painel de informações. Não utiliza arquivos externos ou algo do tipo! simplesmente, copie e cole no seu codigo da forma que o codigo foi escrito. O painel exibe; Ativo Preço do ativos Sua posição(Comprada ou vendida) Preço max e minimo do ativo Nome do usuario Lucro em aberto Saldo

Rsi close/ mtf use

MTF divergence settings

The DD_Relative function calculates the drawdown (relative loss) of the current trading account in percentage. To do this, it uses the Current_LossOrProfit() function to get the current profit or loss for all open positions and divides it by the current account balance. The result is rounded to two decimal places and displayed in the chart comment. The Current_LossOrProfit() function loops through all open positions in the account and adds the commission, swap, and current profit or loss for each position. The result is rounded to two decimal places and returned as the current profit or loss of all open positions.

The function takes two arrays of integers as parameters: "allowedPeriods" and "periodsToCheck". "allowedPeriods" is an array containing all the time periods allowed by the system, while "periodsToCheck" is an array containing the time periods used by the user in the indicator. The function iterates through the elements of the "periodsToCheck" array and checks if each of them is present in the "allowedPeriods" array. If it finds any time period that is not allowed, the function returns "false". If all time periods are allowed, the function returns "true". In short, this function is used to make sure that the time periods used in an indicator are valid and allowed by the system.

123456789101112131415161718192021222324252627282930313233343536