Spread bets and CFDs are complex instruments and come with a high risk of losing money rapidly due to leverage. 69% of retail investor accounts lose money when spread betting and/or trading CFDs with this provider. You should consider whether you understand how spread bets, CFDs, OTC options or any of our other products work and whether you can afford to take the high risk of losing your money.

A complete guide to algorithmic trading

Algorithmic or automated trading is a concept that involves opening and closing trades using computer-based software. It can encompass strategies such as arbitrage, high-frequency trading, mean reversion, backtesting and more, and is often seen as a time-efficient method in comparison with manual trading. Continue reading to discover how to use algorithmic trading and apply your strategies on platforms such as MetaTrader 4 (MT4).

What is algorithmic trading, and how does it work?

In simple terms, it’s the process of using a computer program that follows instructions based on mathematical formulae, in order to make automated trading decisions. By following the algorithm’s instructions, the computer makes decisions for the trader on whether to buy or sell within various financial markets, often by monitoring price charts. It will exit the position once the algorithm’s specified requirements are met.

This type of trading is an effective way of minimising risk when executing an order, as once the trader has chosen the model’s predefined principles, such as the exit price and position size, the computer makes the decisions based on this information. This lessens the likelihood of the trader making decisions based on emotion, rather than logic.

Algorithmic trading software is predominantly used by hedge funds and investment banks, as this is most suitable for large orders, whether that be size or volume. Today, somewhere between 60 and 73% of share trades on US stock exchanges originate from automated orders, according to Wall Street data.

What are some notable strategies?

There are several algorithmic trading strategies that can be adopted by traders to save both time and money. Find out more below.

High-frequency trading

This involves placing a high volume of trades at a rapid speed with the aim of profiting from small movements in price. Typically, positions will be open for less than a minute, or even milliseconds. The aim of high-frequency trading​ is to make small profits, so there are often very high volumes of these type of trades.

Arbitrage

An arbitrage strategy​ involves using an algorithm to monitor the market for price differentials. This could be when two assets with identical cash flows aren’t trading at the same price, or when the same asset isn’t trading at the same price on all markets. This could be useful if, for example, a stock is valued at one price on the New York Stock Exchange, but for less on the London Stock Exchange. This stock could be bought at the lower price on the NYSE, then sold on the LSE for a profit.

As these price differentials aren’t very common, it’s useful to have an algorithm to highlight when they do occur. As these price differentials are often small, a large position is generally required to make a significant profit.

Mean reversion

Mean reversion​ assumes that even if the price of a stock deviates, due to factors such as breaking market news, over time it will move back to the average price. The trading range of a particular asset needs to be identified, and then the average price is detected. Typically, the average asset price is calculated using historical data.

VWAP trading

The volume-weighted average price (VWAP) is a benchmark that traders can use to execute an order as close to the average intraday price as possible. This looks to calculate an asset’s typical price by multiplying it with volume for a selected period (eg one minute). You then keep a running total of cumulative total price volume (TPV) and cumulative volume, just adding volumes for each 1-minute period, or for whichever period the trader has selected, and then divide cumulative TPV by cumulative volume.

These types of statistics may not be useful for determining trends as they are purely a historical average for that day; however, they can be used to gauge whether or not a trader has overpaid for an asset earlier in the trading day.

TWAP trading

The time-weighted average price (TWAP) indicator aims to execute the order as close to the average price of the security as possible, over a specific time period. This is often over the course of one day, and a large order will be split into multiple small trades of equal volume across the trading day. The purpose of this strategy is to minimise the market impact by executing a smaller volume of orders, as opposed to one large trade which could impact the price.

Example of an automated trading platform: MetaTrader 4 (MT4)

MetaTrader 4 is the world’s most popular platform for several reasons, one being that it allows full automation of trades. With MT4, you can trade contracts for difference (CFDs) on a wide range of instruments such as forex, indices, and commodities. Users also have access to various chart types and are able to apply technical indicators, draw tools and add-ons to charts.

Get started by opening an account with us or follow the link to download MT4 for PC and Mac.

Learn more about our automated trading platform
  • Tight and competitive spreads on 200+ instruments, including 175 forex pairs

  • Fast, 100% automated execution

  • Trade on forex from 0.0 pips with our exclusive FX Active account

  • Gain assistance from trading robots known as Expert Advisors

What are Expert Advisors?

Expert Advisors (EAs) are programs that run on the MT4 platform, built using MetaQuotes’ programming language. Their purpose is to monitor the financial markets by analysing price data and signals. Then, based on the parameters that you set, the EAs spot opportunities for trading and enter and exit multiple positions using an algorithm. The amount of human input may vary depending on how specific you want your trades to be.

Someone may choose to use Expert Advisors if trading isn’t their full-time job, as it prevents the need for constant monitoring of markets and open positions. Some traders may prefer to simply keep an eye on profit and loss and close out positions if the strategy isn’t working for them.

Read our complete guide on how to get started with MT4​, including creating your own technical indicators and EAs.

Which markets can you trade?

There are platforms around the world that offer access to stocks, commodities, and bonds, although forex automated trading is perhaps the most common. This type of trading can be useful when hedging trades; in particular, spot contracts; where foreign currencies are bought or sold for instant delivery.

Triangular arbitrage is one common strategy within the forex market. It involves trading currencies with exchange rate discrepancies, with the aim of making an overall profit, and involves three stages:

  1. Firstly, exchanging the initial currency (a) for a second (b)
  2. Then exchanging the second currency (b) for the third (c)
  3. And finally, exchanging the third currency (c) for the first (a)

This would usually be conducted via a computer, partially due to the rare occurrence of these opportunities, but also due to the speed at which the trades need to be carried out. A large amount of capital would typically be traded due to the fractional differences between currency prices.

What are the benefits of algorithmic trading?

  • It avoids the likelihood of human error, caused by factors like emotion or fatigue.

  • Backtesting can be implemented to test a trader’s algorithmic strategy against historical data, in order to improve accuracy and minimise potential risk.

  • Trades are executed more effectively as the computer follows instructions for the optimal buying or selling conditions, as well as timing trades to avoid price changes or slippage.

  • It’s more efficient, as computers can action trades over fractions of a second, something humans simply can’t do. This means less time is spent monitoring financial markets.

  • It can help to reduce transaction costs, due to the lack of human intervention.

  • Complex mathematical calculations that would be too difficult for traders to perform themselves are done within seconds on a computer.

  • It allows traders to use multiple strategies at one time, as well as having a consistent trading plan.

What are the drawbacks?

  • There is a risk that any fault with the algorithm, or internet connectivity problems, could lead to orders not being placed, duplicate orders being actioned, or even erroneous positions being taken.

  • It can lead to spikes in volatility, as these algorithms react to market conditions, potentially widening bid-ask spreads or not placing certain trades, which could ultimately harm liquidity.

  • High-frequency trading can amplify systemic risk by transmitting shocks across markets when combined with other factors. There is an argument that high-frequency trading played a part in the ‘Flash Crash’ in 2010, when the Dow Jones Industrial Average plummeted more than 1,000 points in 10 minutes.

  • Faulty algorithms can cause ripple effects across other markets, resulting in amplified losses.

How to get started

Algorithmic trading can be a complex process, and is mainly used by traders with a higher level of experience and knowledge. Follow the steps below to discover how to automate trading in MT4.

  1. First, open a demo account. This allows you to familiarise yourself with the platform and practise your strategies risk-free with virtual funds.
  2. Read about CFD trading. This a derivative product that uses leverage to give traders greater exposure to the markets, which magnifies potential profits, but also losses. Learn more about the risks of CFD trading​ before you start trading for real.
  3. Brush up on technical analysis. Discover the chart types, technical indicators, and add-ons available on MT4 to aid your automated strategy.

FAQs

Is algorithmic trading illegal?

It isn’t illegal as long as it’s carried out fairly and doesn’t use any form of market manipulation. For example, arbitrage and high-frequency trading are two legal and popularly used strategies within the forex and stock markets.

Can you make money with this technique?

As automated trading aims to make small but frequent profits from short-term price movements, it can amount to a larger overall profit if executed successfully. However, highly liquid markets can also be volatile, so it’s important to implement risk-management controls such as stop-loss orders as part of a complete strategy in order to prevent losses.

How do I become an algo trader?

To get started on the international MetaTrader 4 platform, sign up for an MT4 demo account. You can practise first with £10,000 worth of virtual funds to familiarise yourself with the platform and range of instruments on offer.

CMC Markets is an execution-only service provider. The material (whether or not it states any opinions) is for general information purposes only, and does not take into account your personal circumstances or objectives. Nothing in this material is (or should be considered to be) financial, investment or other advice on which reliance should be placed. No opinion given in the material constitutes a recommendation by CMC Markets or the author that any particular investment, security, transaction or investment strategy is suitable for any specific person. The material has not been prepared in accordance with legal requirements designed to promote the independence of investment research. Although we are not specifically prevented from dealing before providing this material, we do not seek to take advantage of the material prior to its dissemination.

Ready to find your flow?

start trading with a live account or
Try a demo with £10,000 of virtual funds.