A complete guide to algorithmic trading
Learn about algorithmic trading, how it works, and how to connect your MetaTrader 4 (MT4) account with Capital.com.
What is algorithmic trading?
Algorithmic trading, often referred to as ‘algo trading’, uses computer algorithms to automatically execute positions. It’s used in an attempt to implement trading strategies more efficiently and accurately than manual methods.
Rather than manually placing buy or sell orders, algorithmic trading software makes decisions based on predefined conditions. These conditions could involve market indicators such as price, volume or time. Once these conditions are met, the algorithm will execute the trade instantly, provided there is sufficient liquidity.
Algorithms can potentially reduce the occurrence of human error by removing some of the emotional biases from trading.
Types of algorithmic trading
There are a few types of algorithmic trading that function in differing ways, ranging from breaking down large trades to minimise market impact, to capitalising on market inefficiencies.
Execution algorithms
Execution algorithms include VWAP (Volume Weighted Average Price) and TWAP (Time Weighted Average Price), which are designed to carry out large orders with minimal market impact. They achieve this by breaking down large trades into smaller ones, executed periodically to reduce costs like slippage and achieve the best price possible.
Profit-seeking algorithms
Profit-seeking algorithms aim to maximise returns by identifying inefficiencies, patterns or statistical arbitrage opportunities in the markets. Often used in high-frequency trading (HFT) strategies, these algorithms are often less transparent than execution algorithms, as traders or firms may keep their proprietary strategies secret.
Black-box algorithms
Black-box algorithms refer to algorithms where the internal logic, code or rules aren’t transparent or easily understood by users. They’re often built using complex statistical models like machine learning or neural networks, where the relationships between inputs and outputs are not always clear.
Open-source algorithms
Open-source algorithms are algorithms where the code and logic are fully accessible, available and modifiable by the public, unlike black-box algorithms. Users can inspect, modify or improve them as they see fit.
What is an algo trader?
Algo traders are market participants who use algorithms to automate their trades. Historically, algorithmic trading was exclusive to large financial institutions with access to high-powered systems and technical expertise.
Today, however, platforms like MetaTrader 4 (MT4) make algo trading more accessible with advanced strategy building, automation and backtesting tools that don’t require advanced coding skills.
Many algo trading platforms offer pre-built trading algorithms – often called Expert Advisors on MT4 – with parameters that you can customise based on your trading strategy and risk tolerance. Alternatively, traders with programming knowledge can develop algorithms using languages such as Python or MetaQuotes Language 4 (MQL4).
How does algorithmic trading work?
Algorithmic trading works by using predefined rules and computer algorithms to automatically execute trades based on market data. These algorithms scan real-time market information to identify trading opportunities and place orders almost instantly. By removing human emotion and minimising error, algorithmic trading allows trades to be executed with greater precision and speed.
For example, a trader might create an algorithm based on technical analysis, like moving averages or price patterns. When the market conditions match the rules set by the algorithm, it triggers a buy or sell trade without the need for manual input.
Algorithms can be applied across various markets and asset classes, including stocks, forex and commodities. Some traders use algorithmic trading as part of a high-frequency trading (HFT) strategy to execute numerous trades within milliseconds and respond swiftly to price fluctuations in fast-moving markets.
Algorithmic trading – pros and cons
Benefits – algo trading is faster and more efficient than traditional trading methods, and removes the delay and emotional biases of human decision-making. Algorithms can execute trades at precise moments based on preset conditions, reacting almost immediately to changes in market conditions. Traders can backtest their algo strategies against historical and live data.
Disadvantages – algorithms are created by people, meaning the risk of human error remains. A small mistake in coding or strategy could lead to substantial losses, even when properly tested, because past performance does not guarantee future results.
What’s the difference between algorithmic trading and automated trading?
Algorithmic trading and automated trading are often used interchangeably, but they have distinct meanings.
Algorithmic trading involves automatically executing trades based on predefined rules and criteria – such as asset price, volume and the differentials between correlated markets. These algorithms use technical analysis and statistical models to make informed trading decisions.
Automated trading is a broader term, referring to any system where trades are executed without human intervention, regardless of whether algorithms or predefined strategies are used. This includes basic functions like limit orders and stop-losses, which execute automatically once specific conditions are met.
Then there’s quantitative trading, which also uses algorithms and statistical models to identify market opportunities. Here’s more on the focus, tools and usage for each approach.
Aspect | Quantitative trading | Algorithmic trading | Automated trading |
Focus | Data-driven strategy development | Automated trade execution | Includes all forms of automation in trading |
Tools | Statistical models, algorithms, backtesting | Pre-programmed trade execution rules | Algorithms, AI, machine learning, trade execution platforms |
Usage | Often by large institutions, but increasingly accessible to individuals | Retail traders, institutions, and hedge funds | Retail traders, institutions, and hedge funds |
Algorithmic trading strategies
Algorithmic trading strategies involve computer algorithms designed to automatically execute trades based on predefined rules. These techniques provide a disciplined, data-driven approach that can be customised to your individual trading preferences and risk tolerance.
Here are some common popular algorithmic trading strategies:
Statistical arbitrage strategy
Statistical arbitrage involves using statistical models that automatically execute trades based on temporary deviations in the historical price relationship of two or more correlated assets.
The algorithm analyses large sets of historical data to identify these relationships. When a price divergence occurs, and the algorithm determines it is unlikely to persist, it opens trades based on mean reversion theory – assuming the assets will eventually return to their historical price relationship.
For example, a trader creates a statistical arbitrage algorithm that monitors the prices of two highly correlated commodities. When the price of Commodity A rises while Commodity B remains static, despite their historical correlation, the algorithm takes a long position on Commodity B and a short position on Commodity A, anticipating their prices will reconverge.
Volume Weighted Average Price (VWAP)
Volume Weighted Average Price (VWAP) aims to execute large orders over time with minimal impact on the market price. VWAP is calculated by taking the average price of an asset throughout a trading period, weighted by volume. The algorithm seeks to execute trades at intervals that approximate this average price.
This strategy can be useful in conditions where placing a large trade could significantly move the market price. The algorithm breaks the order into smaller chunks, and executes them at intervals to reduce market impact, helping to fill the order at a price close to the VWAP.
Example: A trader wants to buy 10,000 shares of a stock but aims to avoid pushing the price higher by placing a large single order. The algorithm uses VWAP to break the trade into smaller orders over several hours, executing each one at a price that reflects the stock’s volume-weighted average throughout the trading day.
Time Weighted Average Price (TWAP)
The Time Weighted Average Price (TWAP) strategy is similar to the VWAP strategy but focuses purely on time rather than volume.
In this strategy, the algorithm splits an order into equal-sized trades that are executed at regular intervals over a specific time period. The goal is to achieve an average price by spreading the order across multiple trades, minimising impact on market price.
TWAP is often used in situations where traders want to minimise market impact and avoid influencing sentiment by placing a large order all at once.
Example: A trader wants to exit a large position in a low-liquidity forex pair. To minimise market disruption, they set up a TWAP algorithm to split the trade evenly into smaller parts and execute them at regular intervals. This strategy helps ensure the best possible average exit price while reducing market impact.
Steps to start algo trading
To start algo trading, MetaTrader 4 (MT4) is one of the more user-friendly and popular platforms to use, due to its flexibility and extensive tools. You can connect your MT4 account to ours with ease and start algo trading seamlessly.
You can develop your own algorithms using MT4’s built in coding language or choose from one of many customisable Expert Advisors (EAs) – pre-programmed trading bots that use algorithms to automate your strategies.
Here are five steps to start algorithmic trading:
1. Open a trading account:
Sign up with an online trading platform that supports MetaTrader 4 and download the MT4 platform.
2. Connect your trading account:
Once your trading account is live, link it to MT4.
3. Choose or build an algorithm:
Pick from a variety of pre-built algorithmic trading bots that you can tailor to your strategy, or develop your own using the MQL4 programming language.
4. Backtest your strategy:
Backtest your algorithm using real market data with MT4’s StrategyTester tool to refine your trading strategy before trading in real-time.
5. Monitor performance:
Adjust your strategy and algorithm based on performance or changing market conditions.