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

Select the last closed deal (trade) to further work.

This EA help you for Auto set the TP & SL by default parameter, Auto trailing stop & step for any order that you place from any device, Easy way to close all orders with 3 Button "Close All" "Close Profit" "Close Lose", Auto close all orders by profit or lose treshold value

QuickTradeKeys 123 is a user-friendly Expert Advisor (EA) for MetaTrader 5, enabling traders to execute buy and sell operations quickly by simply pressing the numbers '1' and '2' on their keyboard. Pressing '3' closes all open positions. This EA is ideal for swift trading and testing purposes where manual intervention is required without using the mouse.

A simple yet effective donchian channel breakout strategy. This strategy is timeless!

Here are some examples of codes for set counters based on "Count"

If you only want to execute your code blocks "only once per bar" it's important to check if there is new bar arrived or not.

This code block loops through all opened position and do trailing based on Ask and Bid prices.

This code block detects a New Bar or a New Candle when it has received.

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

123456789101112131415161718192021222324252627282930313233343536