Monday, January 23, 2017

Learn the BEST


Algo trading: the basis for automated trading

Trading in the financial markets used to be carried out verbally or visually by the traders on the exchange floors until the early 1990’s, when the computers started to be introduced to the industry. Nowadays, trading is almost entirely computerized, meaning that financial instruments are quoted electronically and traders buy and sell these instruments through electronic platforms. Along with the introduction of the computers to the industry came algorithmic (algo) trading which is carried out automatically by computer software or robots. Algo trading has evolved a great deal since the late 1980s. Trading in many large investment firms is now done through algorithmic trading software, apart from their teams of professional traders and analysts.

Algo trading robots have an important role in forex
Algo trading robots have an important role in forex.

What is algorithmic trading?

Some types of computerized trading have existed since the late ‘70s, but they mainly order programs to help traders execute trades on many stocks and currency pairs in a short period of time. They don’t analyze the market - the trader must decide on the trades, therefore, they cannot be considered algorithmic trading programs. Algorithmic trading software are programs developed by traders, mathematicians or statisticians who decide by themselves what stocks or currency pairs to buy/sell and when to execute trades. They trigger a trade when the strategy it is based on has reached all the right parameters. The strategy might be based on a formula, on technical indicators, on statistics, on mathematical games etc., which has been set up by the developers. Many big firms which participate in the financial markets, such as investment banks, hedge funds, and/or pension funds etc., use algorithmic trading these days. Algorithmic trading strategies have been implemented through designed Excel spreadsheets, but now they are mainly implemented through advanced programming language. The big firms and brokerages usually use the FIX Protocol's Algorithmic Trading Definition Language (FIXatdl). It is a very reliable program and allows collecting of orders and execution exactly as specified.

Algo for MT4

Many retail traders use the MetaTrader4 platform, which is very friendly for algorithmic trading. The MQL4 programming language of the MT4 makes it very easy to create and implement trading scripts, robots and Expert Advisors (EAs). It also allows you to back-test your algo strategy against the historical data and charts. This is very useful because you can actually see if the strategy would have worked in real market conditions in the past, thus saving you time and money you would have lost if the strategy is not successful. To build or import an algo trading strategy in the MT4, you right click on the Expert Advisors section in the navigator window and choose ‘create’, ‘buy’ or ‘import’. If you want to create your own algo strategy you can do it in the MT4 Editor. When you click create, a page like this one below will appear where you can put the strategy on the script. Don´t forget to give your algo a name, such as ‘RoboTrading’, so you can find it easily when you search for it in the MT4 platform. Then, back-test it by clicking ‘view’ and ‘strategy tester’. Select your new RoboTrading algo strategy, choose a forex pair or a stock and click on the journal to see how it would have performed in a live market from the past.


Algo strategies

High frequency trading – High frequency trading (HFT) is one of the most popular algo strategies and it is used primarily by large participants, such as hedge funds and investment banks since it needs very advanced and expensive technology as well, like low or no spreads. It consists of several short-term trades usually lasting less than a second. The HFT strategies are based on robots that buy large amount of financial instruments and sell them in as short a time as a millisecond. The profit from a single trade is very minimal, but when you take into the large numbers of trades the profit adds up. HFT provides liquidity to the markets, since it has a very high trading volume. It´s because of this that many exchanges pay a rebate to the HFT firms for every trade, so that´s another source of income for these firms. HFT has also helped in reducing the buy-sell spreads.    

HFT has increased the liquidity of the forex market

HFT has increased the liquidity of the forex market

Scalping – Scalping is the second most popular trading strategy in use by algorithm trades after high frequency trading. While in HFT the trades only last less than a second and target less than a pip, in scalping trades last from a few seconds to a few minutes and the profit target is several pips. The scalping algos strategy is to take advantage of small market fluctuations, buying during a quick price jump/spike and selling a few minutes later when the jump is over. Algo trading is perfect for scalping because you get the best entry and exit price possible since trades are executed automatically by robots. This is crucial when only targeting a few pips.

Formula trading – Many mathematical and algebraic formulas have been formulated over the years in order to predict the financial markets. Most of these formulas are very complex and the human mind cannot calculate them continuously so they are best used by algorithmic computer programs. The algo program makes the calculation instantly and takes trading decisions based on these calculations. There are also algos that are based on easier and less complex trading formulas. One of them is buying a forex pair when it had a losing day after six straight days of gains. The logic behind that is that if it made six consecutive days of gains, it is bound to go up further and the losing day is considered as a retrace period.  

Trend following – Algo programs built to follow trends vary and are based on different trend indicators. Some of them base their strategy on trend lines; they pick trendy pairs and buy or sell whenever the price touches or gets close to the trend line. Others are based on channels which means they buy at the bottom line on an uptrend or sell at the top line on a downtrend. There are many trends following strategies for algo trading, another one being the moving average crossover. This strategy uses two moving averages of different periods, let´s say a 20 and a 40 moving average. When the 20 moving average crosses over the 40 moving average it means that a trend is starting. The algo program detects the crossover and executes the trade in the same direction as the crossover.

Trend reversing – Similarly to the trend following algorithm programs, the algos that are built based on this strategy detect trends. The difference is that they don´t trade in the direction of the trend, but wait until the trend is over and then open a trade in the opposite direction. The signal which indicates the end of the trend might be a pin or a doji candlestick, stochastic or RSI reaching the overbought or oversold area etc. Trend following and trend reversing algorithm systems are the easiest to build since they use technical indicators, which are easily detected and implemented by the system. Apart from that, there´s no difficult formulas that try to predict price action.  

As you can see, algorithm trading has gone a long way since it is started in its early days. Many large investment firms also use algo programs for their work. The development of algo trading systems has led to a rapid increase in high frequency trading, which peaked in 2009-2010 when it accounted for about 60% of the trading volume. Since then, it has declined in the last 5 years and now it accounts for about 35% of trading volume in Europe and USA. HFT needs uses very sophisticated and expensive computers and software, but there simpler algorithmic trading strategies which you can build yourself and which work perfectly on a normal PC with MT4, as we explained above. In the following articles of the algo trading series we will explain how to build your own algorithm systems.