To Make a Trading Robot, You Need a Trading System
Trading on financial markets involves many risks including the most critical one - the risk of making a wrong trading decision. The dream of every trader is to find a trading robot, which is always in good shape and not subject to human weaknesses - fear, greed and impatience.
Each newcomer wants to get or create a clear and strict trading system that can be presented in the form of algorithms and completely get rid of routine operations. Is it possible?
A trading system is a necessary condition for entering the market and that system should be profitable, of course. When newcomers come to the market, they are usually overwhelmed by the great mass of information difficult to grasp. Books and trader forums can provide some help in that case.
Unfortunately, not all authors are successful traders and not all successful traders write books. Many special web resources are created only to earn profit for their owners, as it is much more difficult to trade your own money than to issue forecasts and teach trading systems.
Each trader should independently pass all stages of a trading system creation. There is a popular saying that it does not matter what system you use for trading, the main thing is that you should really trade according to that system. Otherwise, trading on the market turns into a gamble with a predictable result.
Trading Robots and Forex
Forex market is believed to have a great liquidity. Also, it allows trading 24 hours a day, unlike many other markets. Therefore, many traders try to make trading robots specially for Forex market, as it offers a large number of trading instruments.
However, skeptics claim that all currency pairs are strongly correlated with each other providing very low volatility in the market. But their opponents respond that each currency pair has its own features and low volatility is compensated by a big leverage.
In any case, Forex instruments are attractive for making trading robots and most supporters of the automated trading hone their skills on currency pairs.
How to Start Making a Trading Robot?
There are many approaches to building an automated trading system. We will describe only a few major ones.
The first approach rests on math. A developer tries to create a sort of an equation that can consider many factors. This approach is based on the firm belief that price movements are managed by a model that can be found using available historical data.
In most cases, the followers of such an approach know too much math but know nothing about/are not interested in the market. The market is a pure abstraction, a type of an intellectual game for them. This approach usually leads to many years of study and development, while a definite result in the form of a working automated trading system is not so important.
The second approach is based on studying the market laws. No attempts are made to understand why the price goes up or down when various technical analysis figures appear on a chart. The advantage of this approach is that it requires no special knowledge of mathematics and makes no assumptions about the market driving force.
It is most clear and convenient when studying trading. It is most popular among traders who received universal recognition. The disadvantage of the approach is the necessity to constantly track all necessary symbols.
Sooner or later, a trader starts considering automation of trading processes and the most considerable issue appears at that stage – complexity of formalizing trading rules when trying to express them in the form of algorithms. In some cases traders who try to order a trading robot cannot describe trading rules and find common ground with programmers.
The third approach is based on the attempt to create a «black box» based on neural networks with the use of the ready-made tools widely available in special software and math packages. Creation of an automated trading system with the elements of the artificial intelligence is an exciting and challenging task even for newcomers, as it requires neither deep mathematical background, nor programming experience - everything is done using visual aids.
A trader should know the basics of technical indicators, possess an ability to prepare necessary price data and experience in some definite package for working with neural networks. The main drawback of this approach is that a trading robot obtained using such specialized tools for working with neural networks is actually a "black box". Traders do not know its working principles and, generally, it is impossible to predict what market phase will be the most problematic for the robot.
Programmers often choose the fourth approach – they start making a trading robot from the very beginning without spending time for manual trading. Why trade manually? You can make a robot spending a few months and reap the benefits of your efforts then.
But «no pains, no gains». In most cases, programmers start creating all necessary infrastructure using a familiar programming language rather than just making a trading robot – getting and processing price data, visual representation of charts and indicators, custom means of testing strategies on historical data and so on.
They gain much experience in the process. But in most cases, that experience does not bring them closer to the final goal – creation of an automated trading system. And even if a trading robot is created, there is no guarantee that it will be profitable. And what if a programmer wants to write another trading system? Deep restructuring and new programming errors are inevitable.
There is also the fifth approach – buying a ready-made trading system in the form of a trading robot. In this case, a trader acts as an operator or a tuner. This approach saves much time (no need to learn many new things) and allows traders to quickly enter the world of the automated trading.
The main drawback of this approach stems from its advantages – you don't know the operation principles of your trading robot and its structure. And even if a seller has provided you with a detailed description of the implemented trading system, you will never be completely sure in it.
However, neither of the mentioned approaches can give you absolute guarantee except a bank deposit. But that is not a very suitable solution for people interested in market trading and ways to increase their private assets.
What is the Best Approach to the Automated Trading for a Trader?
Each of the five described approaches has its advantages and corresponds to some definite type of trader. It is unlikely that you will choose the first approach (market analytical description) without good mathematical background. It is equally unlikely that you will start from making trading robots based on neural networks. However, both of these approaches are very exciting and provide good intellectual exercise.
Below we will discuss only the second approach, which is already considered to be the classical one. That is the approach usually chosen by new followers of the automated trading, as the technical analysis remains the key knowledge area when learning trading basics.
Another advantage of the second approach is that after you spend some time for manual trading and obtain the sense of the market, you will already have a good understanding of technical analysis tools. Besides, you will be able to program trading strategies or create neural networks on a higher level.
The First Steps in Making a Trading Robot
To make an automated trading system, you need programming skills and knowledge of all intricacies of trade requests processing. But first you can start from the ready-made Expert Advisors – trading robots from the free Code Base library.
Download any Expert Advisor (trading robot) and launch it in the Strategy Tester of MetaTrader 4 or MetaTrader 5 client terminals. Select a history interval showing a strong trend and an interval with a flat. Perform optimization of an Expert Advisor input parameters and examine their differences at these two intervals.
Launch an Expert Advisor with the optimal parameters for a flat on a trend interval and with the optimal parameters for a trend on a flat interval. Examine the differences in trading results, deals distributions and other statistical parameters. As a result, you will know how much the behavior of your trading system can vary when the market situation changes.
It would be better to try several standard trading strategies using this method on different parts of history and various symbols. Such a trial run prevents from fitting a trading system for some definite history interval and provides better understanding of trend and countertrend systems.
The next step would be to create more complex trading systems based on the combination of already existing simple signals from MQL5 Wizard set. You can test and develop your trading intuition sorting out bad signals of one system using a filter based on another system without programming means.
The main thing here is not to overachieve. The more input parameters a trading system has, the easier it is to be fitted. There have been a lot of discussions about the differences between optimization and fitting. There are no widely accepted solutions here. But visualization of test/optimization results and your own common sense can help you.
Learn to identify the most critical input parameters affecting your trading system from the whole set of input data. Do not pay much attention to secondary parameters that take time during optimization but do not affect the very logic of the system. Remember that a good trading system always demonstrates a small free motion of secondary parameters but it does not display dramatic volatility in case of inconsiderable market changes.
You can spend as much time at this stage, as you wish, until you are sure that you can understand any trading strategy examining test and optimization results. The knowledge of strengths and weaknesses of standard systems will allow you to be better prepared when creating your own trading robot.
Programming a Trading Robot
First, you can examine several ready-made trading robots described in the articles to better understand programming intricacies.
Second, you can ask questions on MQL4.community or MQL5.community, if you have any unresolved issues. Experienced community participants usually help the newcomers showing sincere interest in the subject.
Third, you can order imrpovement or development of an Expert Advisor or an indicator in Jobs service, if you are not able to write a necessary program on your own. But even if you make an order via the freelance service, you should have some idea about strategy testing to find a common language with a developer.
Besides, basic knowledge of a programming language allows you to implement minor fixes and changes into the code after the work has been already completed. After all, it would not be too convenient to call a programmer to fix every small issue you encounter. It would be much more easier and faster to fix it yourself.
No Need to Reinvent the Wheel
How to find your own trading strategy, or at least in what direction should you focus your search? All traders protect their own trading systems, if they have one. All newcomers want to create a profitable system or get a ready-made one. At the same time, any obtained solution seems to be too simple compared to newcomers' ideas about a genuine trading system.
Army men all over the world are prone to excessive levels of secrecy. There are many jokes about that including the following one: "The military secret is not in what you are studying, - an officer says to military school students, - but in the fact that exactly you are studying it". The situation with trading systems is similar enough: most traders use simple and well-known trading ideas with minor modifications, for example, adding Trailing Stop or confirmations from trend indicators.
There are plenty of trader forums with limited access where participants join their efforts to develop or improve some secret trading systems. Most interesting thing is that such systems do not contain anything special at all. Usually a well-known idea (like "trade with the trend") is used as a basis. Then it is perfected with some new indicators unknown to general public.
Therefore, you can easily take available trading robot source codes and try to use them correctly with various symbols and timeframes. Another popular saying can be mentioned here: "You don't like cats? You just don't know how to cook them!" It is hard to believe but the probability that you will develop something really new is very small. The main thing here is to create a system using available ingredients. Do not think that some geniuses have access to some secret systems from NASA laboratories. That is the secret of the Grail.
Only a Few Will Make It Through
So, why does no one use trading ideas, if they are literally within arm's reach? The answer probably lies in human psychology. The staff of many banks and large investment funds includes traders performing deals according to strict rules and within limited volumes. But for some reasons, only a few institutional traders leave their companies and start trading using their own money.
It turns out that you need not only a trading strategy but also the iron discipline to follow it. Many traders found out with regret that they also have the same psychological problems described in books. After realizing that the worst enemy of traders are themselves, a newcomer starts thinking about making a trading robot to eliminate a psychological burden.
Though I slightly deviate from the topic, I should mention the legendary Turtles traders who successfully traded on multiple markets in the late 20th century. Read "Way of the Turtle" and you will see that the most important thing for a trader is a self-discipline and not some top secret system. Alas, most newcomers will not be able to follow a profitable strategy, even if they get it for free.
The problem is that most trading strategies that are perfectly fitted for manual trading can hardly be formalized and transcribed to a programming language. The strategies that can be easily formalized (for example, those involving two moving averages' intersection) are too simple and require a lot of refinements and
improvements, so they can be used in practice. Thus, a simple idea is gradually complicated by a plenty of external parameters preventing a trading robot from false entries and errors clearly visible for a developer. A trading robot optimization issue emerges. This process should not turn into an overoptimization and fitting for a particular history interval.
To address this issue, the forward testing using the obtained system parameters has been implemented in MetaTrader 5 terminal. If the forward testing results do not significantly differ from the ones obtained in the optimization section, there is a probability that a trading robot will be stable enough for some time
after its launch on a trading account. A length of an interval for parameters optimization and an actual value of that "some time" depend on a certain trading system.
Thus, the optimization of a trading robot before launching it on a trading account reminds of unwinding a sling - the more carefully we have unwound and flung a projectile from the sling, the farther it will fly and the more accurate its trajectory will be. A thoroughly developed trading robot will keep a positive result on a trading account for a longer time than a trading robot obtained as a result of a fitting. We can say that the Grail is a
working idea and correct adjustment of parameters performed from time to time at the moments of market conditions changes.
This can be illustrated by the results of the Automated Trading Championship that is held for many years already. Submitted Expert Advisors of all the participants pass through automatic tests on the time interval from January to the end of July. The main requirement for passing the automatic test is a profit earned for eight months of testing. But less than a half of trading robots admitted for the Championship remain profitable after thee months of autonomous work.
You can also try your skills in making and adjusting your trading robot to take part in the Championship and get the forward testing results of your Expert Advisor. Besides, the participation is free and the awards are impressive. We hope to see you there!
Professional intraday traders spend many hours sitting at their computers and waiting for the right moment to perform a deal. Of course, they cannot be in good shape all the time.
Most traders come to the conclusion that their actions violate their own trading rules. Not all trading systems can be completely formalized but even such systems can in most cases adopt additional tools, such as indicators, analytical systems and false signals filters.
We do not make any special recommendations here concerning MQL4 or MQL5 languages learning, as there are a lot of other useful articles concerning that subject. The purpose of this article was to provide some initial idea about how to start making your trading robot for MetaTrader 4 and MetaTrader 5 terminals.
We hope that this article will save time for newcomers and show the right direction in the difficult task of developing an automated trading system.
Translated from Russian by MetaQuotes Software Corp.
Original article: https://www.mql5.com/ru/articles/443