Write your own algorithmic trading robot

Many traders aspire to become algorithmic traders, but it is difficult to code their trading robots correctly. These traders often find messy and misleading algorithm-encoded information on the Internet, as well as false promises of getting rich overnight. However, one potential source of reliable information comes from Lucas Liew, the creator of the online algorithmic trading course AlgoTrading101. Since its launch in 2014, the course has attracted more than 30,000 students.

Liew’s course focuses on presenting the basic principles of algorithmic trading in an organized way. He firmly believes that algorithmic trading is “not a plan to get rich quick.” Below is an overview of the basics (from Liew and his course) required to design, build and maintain your own algorithmic trading robot.

Key points

  • Many aspiring algorithmic traders find it difficult to find the right education or guidance to properly code their trading robots.
  • AlgoTrading101 is a potential source of reliable guidance and has received more than 30,000 visits since its launch in 2014.
  • Trading algorithms or robots are computer codes that identify trading opportunities and can execute entry and exit orders.
  • In order to be profitable, robots must recognize regular and continuous market efficiency.
  • Although examples of get rich quick plans abound, it is best for aspiring algorithmic traders to have moderate expectations.

The rise of robo-advisors

What is a trading robot?

At the most basic level, an algorithmic trading robot is a kind of computer code that can generate and execute buying and selling signals in the financial market. The main components of this robot include entry rules that indicate when to buy or sell, exit rules that indicate when to close the current position, and position size rules that define the quantity to buy or sell.

Obviously, you will need a computer and internet connection to become an algorithmic trader. After that, a suitable operating system is needed to run MetaTrader 4 (MT4), which is an electronic trading platform that uses MetaQuotes Language 4 (MQL4) to encode trading strategies. Although MT4 is not the only software that can be used to build robots, it has many significant advantages.

One advantage is that although the main asset class of MT4 is foreign exchange (FX), the platform can also be used to trade stocks, stock indexes, commodities and Bitcoin using Contracts for Difference (CFD). The other advantage of using MT4 (compared to other platforms) is that it is easy to learn, it has many available foreign exchange data sources, and it is free.

Algorithmic trading strategy

The first step in developing an algorithmic strategy is to reflect on some of the core characteristics that each algorithmic trading strategy should have. This strategy should be market prudent, because from a market and economic point of view, it is fundamentally reasonable. In addition, the mathematical models used to formulate strategies should be based on sound statistical methods.

Next, determine what information your robot wants to capture. In order to develop an automation strategy, your robot needs to be able to capture recognizable and persistent market inefficiencies. Algorithmic trading strategies follow a set of strict rules, use market behavior, and one-time market inefficiencies are not enough to develop strategies around. In addition, if the cause of market inefficiency cannot be determined, then there will be no way to know whether the success or failure of the strategy was accidental.

Considering the above, there are many types of strategies that can provide information for the design of your algorithmic trading robot. These include strategies that utilize the following (or any combination thereof):

  • Macroeconomic news (for example, non-agricultural employment or interest rate changes)
  • Fundamental analysis (for example, using revenue data or earnings release notes)
  • Statistical analysis (for example, correlation or cointegration)
  • Technical analysis (for example, moving average)
  • Market microstructure (e.g. arbitrage or trade infrastructure)

Preliminary research focuses on developing strategies that suit your personal characteristics. When formulating a strategy, factors such as personal risk profile, time commitment and transaction capital are all important considerations. Then, you can start to identify the aforementioned persistent market inefficiencies. After determining that the market is inefficient, you can start writing a trading robot that suits your personal characteristics.

Backtesting and optimization

Backtesting focuses on verifying your trading robot, including checking the code to ensure that it is acting according to your wishes, and understanding the performance of the strategy in different time frames, asset classes or market conditions, especially in the so-called “black swan” event For example, the financial crisis of 2007-2008.

Now that you have written a working robot, you will want to maximize its performance while minimizing overfitting bias. In order to maximize performance, you first need to choose a good performance measure that captures the elements of risk and return and consistency (such as the Sharpe ratio).

At the same time, when your robot is too close based on past data, there will be an overfitting bias; such a robot will give people an illusion of high performance, but since the future will never be completely similar to the past, it may actually Will fail. Using more data for training, removing irrelevant input features, and simplifying the model may help prevent overfitting.

Site execution

You can now start using real money. However, in addition to preparing for the emotional ups and downs you may experience, there are some technical issues that need to be resolved. These issues include choosing the right broker and implementing mechanisms to manage market risks and operational risks, such as potential hackers and technical downtime.

Before going online, traders can learn a lot through simulated trading, which is a process of using real-time market data instead of real currency to practice strategies.

In this step, it is also important to verify that the performance of the robot is similar to the performance experienced during the testing phase. Finally, monitoring is required to ensure that the market efficiency of robot design still exists.

Bottom line

It is perfectly reasonable to teach inexperienced traders a set of strict guidelines and achieve success. However, aspiring traders should remember to have moderate expectations.

Liew emphasized that the most important part of algorithmic trading is “understanding what type of market conditions your robot will work under and when it will collapse” and “understanding when to intervene”. Algorithmic trading can bring rewards, but the key to success is understanding. Any course or teacher that promises high returns without a full understanding should be the main warning sign to stay away.

.

READ ALSO:   Attribute deviation
Share your love