![Guide to Testing and Optimizing of Expert Advisors in MQL5](https://c.mql5.com/2/0/Testing_Optimization_Guide_MQL5__1.png)
![Guide to Testing and Optimizing of Expert Advisors in MQL5](https://c.mql5.com/i/articles/overlay.png)
Guide to Testing and Optimizing of Expert Advisors in MQL5
This article explains the step by step process of identifying and resolving code errors as well as the steps in testing and optimizing of the Expert Advisor input parameters. You will learn how to use Strategy Tester of MetaTrader 5 client terminal to find the best symbol and set of input parameters for your Expert Advisor.
![Several Ways of Finding a Trend in MQL5](https://c.mql5.com/2/0/Determine_Trend_MQL5.png)
![Several Ways of Finding a Trend in MQL5](https://c.mql5.com/i/articles/overlay.png)
Several Ways of Finding a Trend in MQL5
Any trader would give a lot for opportunity to accurately detect a trend at any given time. Perhaps, this is the Holy Grail that everyone is looking for. In this article we will consider several ways to detect a trend. To be more precise - how to program several classical ways to detect a trend by means of MQL5.
![How to Quickly Create an Expert Advisor for Automated Trading Championship 2010](https://c.mql5.com/2/0/Fast_Expert_Advisor_Writing_MQL5.png)
![How to Quickly Create an Expert Advisor for Automated Trading Championship 2010](https://c.mql5.com/i/articles/overlay.png)
How to Quickly Create an Expert Advisor for Automated Trading Championship 2010
In order to develop an expert to participate in Automated Trading Championship 2010, let's use a template of ready expert advisor. Even novice MQL5 programmer will be capable of this task, because for your strategies the basic classes, functions, templates are already developed. It's enough to write a minimal amount of code to implement your trading idea.
![How to Create Your Own Trailing Stop](https://c.mql5.com/2/0/Trailing_Stop_MQL5.png)
![How to Create Your Own Trailing Stop](https://c.mql5.com/i/articles/overlay.png)
How to Create Your Own Trailing Stop
The basic rule of trader - let profit to grow, cut off losses! This article considers one of the basic techniques, allowing to follow this rule - moving the protective stop level (Stop loss level) after increasing position profit, i.e. - Trailing Stop level. You'll find the step by step procedure to create a class for trailing stop on SAR and NRTR indicators. Everyone will be able to insert this trailing stop into their experts or use it independently to control positions in their accounts.
![The Optimal Method for Calculation of Total Position Volume by Specified Magic Number](https://c.mql5.com/2/0/calculate_volume_MQL5__1.png)
![The Optimal Method for Calculation of Total Position Volume by Specified Magic Number](https://c.mql5.com/i/articles/overlay.png)
The Optimal Method for Calculation of Total Position Volume by Specified Magic Number
The problem of calculation of the total position volume of the specified symbol and magic number is considered in this article. The proposed method requests only the minimum necessary part of the history of deals, finds the closest time when the total position was equal to zero, and performs the calculations with the recent deals. Working with global variables of the client terminal is also considered.
![Processing of trade events in Expert Advisor using the OnTrade() function](https://c.mql5.com/2/0/function_ontrade_MQL5.png)
![Processing of trade events in Expert Advisor using the OnTrade() function](https://c.mql5.com/i/articles/overlay.png)
Processing of trade events in Expert Advisor using the OnTrade() function
MQL5 gave a mass of innovations, including work with events of various types (timer events, trade events, custom events, etc.). Ability to handle events allows you to create completely new type of programs for automatic and semi-automatic trading. In this article we will consider trade events and write some code for the OnTrade() function, that will process the Trade event.
![The Use of ORDER_MAGIC for Trading with Different Expert Advisors on a Single Instrument](https://c.mql5.com/2/0/order_magic_MQL5__1.png)
![The Use of ORDER_MAGIC for Trading with Different Expert Advisors on a Single Instrument](https://c.mql5.com/i/articles/overlay.png)
The Use of ORDER_MAGIC for Trading with Different Expert Advisors on a Single Instrument
This article considers the questions of information coding, using the magic-identification, as well as the division, assembly, and synchronization of automatic trading of different Expert Advisors. This article will be interesting to beginners, as well as to more experienced traders, because it tackles the question of virtual positions, which can be useful in the implementation of complex systems of synchronization of Expert Advisors and various strategies.
![Writing an Expert Advisor Using the MQL5 Object-Oriented Programming Approach](https://c.mql5.com/2/0/Expert_Advisor_classes_MQL5.png)
![Writing an Expert Advisor Using the MQL5 Object-Oriented Programming Approach](https://c.mql5.com/i/articles/overlay.png)
Writing an Expert Advisor Using the MQL5 Object-Oriented Programming Approach
This article focuses on the object oriented approach to doing what we did in the article "Step-By-Step Guide to writing an Expert Advisor in MQL5 for Beginners" - creating a simple Expert Advisor. Most people think this is difficult, but I want to assure you that by the time you finish reading this article, you will be able to write your own Expert Advisor which is object oriented based.
![Functions for Money Management in an Expert Advisor](https://c.mql5.com/2/0/money_management_MQL5__1.png)
![Functions for Money Management in an Expert Advisor](https://c.mql5.com/i/articles/overlay.png)
Functions for Money Management in an Expert Advisor
The development of trading strategies primarily focuses on searching for patterns for entering and exiting the market, as well as maintaining positions. If we are able to formalize some patterns into rules for automated trading, then the trader faces the question of calculating the volume of positions, the size of the margins, as well as maintaining a safe level of mortgage funds for assuring open positions in an automated mode. In this article we will use the MQL5 language to construct simple examples of conducting these calculations.
![Creating an Expert Advisor, which Trades on a Number of Instruments](https://c.mql5.com/2/0/multi_assets_EA_MQL5__1.png)
![Creating an Expert Advisor, which Trades on a Number of Instruments](https://c.mql5.com/i/articles/overlay.png)
Creating an Expert Advisor, which Trades on a Number of Instruments
The concept of diversification of assets on financial markets is quiet old, and has always attracted beginner traders. In this article, the author proposes a maximally simple approach to a construction of a multi-currency Expert Advisor, for an initial introduction to this direction of trading strategies.
![An Example of a Trading System Based on a Heiken-Ashi Indicator](https://c.mql5.com/2/0/Heikin_Ashi_MQL5.png)
![An Example of a Trading System Based on a Heiken-Ashi Indicator](https://c.mql5.com/i/articles/overlay.png)
An Example of a Trading System Based on a Heiken-Ashi Indicator
In this article we look into the question of using a Heiken-Ashi indicator in trading. Based on this indicator, a simple trading system is considered and an MQL5 Expert Advisor is written. Trading operations are implemented on the bases of classes of the Standard class library. The testing results of the reviewed trading strategy, are based on the history, and obtained using the built-in MetaTrader 5 strategy tester, are provided in the article.
![Step-By-Step Guide to writing an Expert Advisor in MQL5 for Beginners](https://c.mql5.com/2/0/create_EA_step_by_step_MQL5.png)
![Step-By-Step Guide to writing an Expert Advisor in MQL5 for Beginners](https://c.mql5.com/i/articles/overlay.png)
Step-By-Step Guide to writing an Expert Advisor in MQL5 for Beginners
The Expert Advisors programming in MQL5 is simple, and you can learn it easy. In this step by step guide, you will see the basic steps required in writing a simple Expert Advisor based on a developed trading strategy. The structure of an Expert Advisor, the use of built-in technical indicators and trading functions, the details of the Debug mode and use of the Strategy Tester are presented.
![MQL for "Dummies": How to Design and Construct Object Classes](https://c.mql5.com/2/0/cube__1.png)
![MQL for "Dummies": How to Design and Construct Object Classes](https://c.mql5.com/i/articles/overlay.png)
MQL for "Dummies": How to Design and Construct Object Classes
By creating a sample program of visual design, we demonstrate how to design and construct classes in MQL5. The article is written for beginner programmers, who are working on MT5 applications. We propose a simple and easy grasping technology for creating classes, without the need to deeply immerse into the theory of object-oriented programming.
![Creating Active Control Panels in MQL5 for Trading](https://c.mql5.com/2/0/panel__2.png)
![Creating Active Control Panels in MQL5 for Trading](https://c.mql5.com/i/articles/overlay.png)
Creating Active Control Panels in MQL5 for Trading
The article covers the problem of development of active control panels in MQL5. Interface elements are managed by the event handling mechanism. Besides, the option of a flexible setup of control elements properties is available. The active control panel allows working with positions, as well setting, modifying and deleting market and pending orders.
![A Virtual Order Manager to track orders within the position-centric MetaTrader 5 environment](https://c.mql5.com/2/0/virtual__1.png)
![A Virtual Order Manager to track orders within the position-centric MetaTrader 5 environment](https://c.mql5.com/i/articles/overlay.png)
A Virtual Order Manager to track orders within the position-centric MetaTrader 5 environment
This class library can be added to an MetaTrader 5 Expert Advisor to enable it to be written with an order-centric approach broadly similar to MetaTrader 4, in comparison to the position-based approach of MetaTrader 5. It does this by keeping track of virtual orders at the MetaTrader 5 client terminal, while maintaining a protective broker stop for each position for disaster protection.
![Creating a "Snake" Game in MQL5](https://c.mql5.com/2/0/snake__2.png)
![Creating a "Snake" Game in MQL5](https://c.mql5.com/i/articles/overlay.png)
Creating a "Snake" Game in MQL5
This article describes an example of "Snake" game programming. In MQL5, the game programming became possible primarily due to event handling features. The object-oriented programming greatly simplifies this process. In this article, you will learn the event processing features, the examples of use of the Standard MQL5 Library classes and details of periodic function calls.
![MQL5 for Newbies: Guide to Using Technical Indicators in Expert Advisors](https://c.mql5.com/2/0/chainik__1.png)
![MQL5 for Newbies: Guide to Using Technical Indicators in Expert Advisors](https://c.mql5.com/i/articles/overlay.png)
MQL5 for Newbies: Guide to Using Technical Indicators in Expert Advisors
In order to obtain values of a built-in or custom indicator in an Expert Advisor, first its handle should be created using the corresponding function. Examples in the article show how to use this or that technical indicator while creating your own programs. The article describes indicators that are built n the MQL5 language. It is intended for those who don't have much experience in the development of trading strategies and offers simple and clear ways of working with indicators using the offered library of functions.