The Ultimate Guide to Stock Market Algorithms

Stock Market Algorithms

You’ve likely heard the term “algorithms” or (algos for short) used in reference to trading. Algorithms run the markets and are responsible for most of the trading volume in the U.S. stock markets on any given trading day. Let’s take the mystery out of stock market algorithms. 

What is a Stock Market Algorithm?

Algorithms are another way of saying “computer programs.” They are simply a set of instructions to perform a task. Stock market algorithms are computer programs that can perform market filtering, analytics, and trade executions in the stock market. They can be as simple as bracket orders or extrapolated a thousand times over with a million lines of code.    

Stock Market Algorithm

How Algorithms Can be Used in Trading

Whatever you can do manually, can be done more efficiently and quickly automatically. Algorithms are automatic and non-emotional. They carry out the instructions step-by-step to perform the task(s) at hand.   

Basic Trading Platform Algorithms

Algorithms can be pre-built, customized, or coded from scratch. Retail traders can utilize ready to use algorithms on their trading platforms if provided. These can be as simple as peg orders, bracket and conditional orders and trailing stops. Anything that performs a set of trading instructions that you can configure is a form of algorithm. If you use a direct access broker, then you very likely have a smart route. Smart routing utilizes algorithms to determine the best route to execute your order based on a certain set of parameters. Algorithms simplify manual tasks quickly and conveniently.

High Frequency Trading

You’ve likely heard of high frequency trading (HFT) programs which can automate numerous trades automatically at millisecond speeds to try to capture the spreads which can be sliced into 10 thousandths of a penny (IE: $27.3323). HFTs perform thousands of trades in rapid succession to capture a small fractional profit which adds up.

HFTs have the advantage of speed, capital, and relentless activity. These are usually used by market makers, hedge funds and institutional traders. HFTs suffered bad publicity during the Flash Crash on May 6, 2010, when algorithms and HFT programs were blamed for the (-1,000) Dow Jones Industrial Average collapse and then recovery 20 minutes later. This triggered stop losses and margin calls in many stocks causing forced liquidations in many cases.

High Frequency Trading

Algorithms Automate Trading Strategies

Depending on your coding prowess or financial backing, most trading strategies can be automated through algorithms. If you can articulate your strategy then an algorithm can be coded for it.

It’s a good idea to articulate your trading strategies through a set of instructions to first familiarize your rules and secondly to someday have it automated via an algorithm. For example, a simple trade set-up strategy could be to buy 100 shares of XYZ when the 50-period simple moving average crosses the 200-period moving average on a 5-minute chart. Then use the 200-period moving average (MA) as a trailing stop. This is a simple algorithm that has the entry (50/200-period MA crossover) and exit (200-period MA trail stop). Add in more conditions and rules to refine your strategy and you will ultimately have the complete instructions to build an algorithm (or pay someone to do it). 

Automated Algorithm Strategy

Benefits of Algorithms

Algorithms take advantage of computer technology and take the legwork out of trading. Speed is a top benefit for algorithms as they follow instructions and rules to determine the trade and then execute that trade. While you may be able to do this simultaneously on two or three stocks at a time, an automated algorithm can do it all of the time on tens to hundreds or thousands of stocks simultaneously and consistently. Those key words, simultaneously and consistently are the key. Algorithms are also devoid of emotion, unlike human traders. Being devoid of emotion enables objective, rule-based, data driven and consistent trading. Scanners and back testing also utilize algorithms to help you make more informed decisions and analysis quicker. 

The Growth in Popularity of Trading Algorithms

What Traders Need to Be Aware Of

After reading this, you may feel like you’ve been left behind on the algorithm trend. However, keep in mind that algorithms are still programmed by humans that have to create the strategies. Going up against a trading algorithm can be futile (like bringing a knife to a gunfight). However, when there are 50 algorithms competing against each other, they can cancel out the advantage which results in their slippage for you to capitalize on (my enemy’s enemy is my friend). If you have a solid trading methodology, it is not necessary to spend time worrying about building your own algorithm. There are thousands of them competing with each other throughout the day reducing their edge. 

Algorithm Awareness

The main thing traders need to do is be aware of algos and how they may impact trading. Algorithms can improve (and take away) liquidity. If 50 algos are trying to sweep up shares of XYZ, then shares will explode higher. Be careful not to chase, because you may lose fast. However, the key is getting in ahead of the signal. If you are already long, then your profits will magnify quicker as you sell into the liquidity of buyers. Seasoned traders may look to short-sell the overshoots to play the reversion off peaks. Algorithms chase liquidity and if you have it, you will be rewarded. Supply liquidity thins out as demand liquidity rises and vice versa. They provide opportunities for nimble traders. Trying to understand potential algos should be your objective when developing a trading system utilizing the common triggers like VWAP crosses, high/low of the day breaks and converging indicator signals. 

Careful with Spoofing

The action of placing lots of bids to nudge prices higher or asks to lean prices lower with no intention to actually get filled is called spoofing. HFTs were once notorious for spoofing to panic buyers or sellers as thousands of bid/ask orders were placed but rarely filled since they could cancel in milliseconds before getting hit. For this reason, level 2 can be dangerous to a beginner because it doesn’t represent the actual trades but the potential for the trades. It’s important to watch the time and sales, which posts actual executions. 

Volatility 

The volatility triggered by algos can be a benefit if you’re on the right side of it and a disaster if caught on the wrong side. For example, if you are short XYZ as the algos sweep (market order selling) the bids collapsing the stock, then you are on the right side of the volatility. If you are long XYZ as the algos sweep the bids, then you’re on the wrong side as prices collapse faster than normal. One of the key arguments against algos is they can cause major volatility by amplifying buying or selling on a massive scale in a short period of time. The key is which side of that volatility you’re on. That’s why it pays to refine and optimize your trading strategy and to understand how algos may be affecting the stocks in which you are trading.

Stock Market Algorithm Volatility


The information contained herein is intended as informational only and should not be considered as a recommendation of any sort. Every trader has a different risk tolerance and you should consider your own tolerance and financial situation before engaging in day trading. Day trading can result in a total loss of capital. Short selling and margin trading can significantly increase your risk and even result in debt owed to your broker. Please review our day trading risk disclosuremargin disclosure, and trading fees for more information on the risks and fees associated with trading.

Related Content

How Do Market Makers Make Money?

How Do Market Makers Make Money?

If you've ever traded stocks, you've probably used a market maker. Market makers are the middlemen of the stock market, and in most cases, these are firms, individuals, and or large corporations that facilitate transactions. For example, if you wanted to buy shares...

How Long Can You Hold a Short Position?

How Long Can You Hold a Short Position?

Investors can hold onto long positions for years or even decades without running into problems. But most short positions are much shorter in duration – a few months to a few years at most. There are several practical limitations that limit how much time traders can...

How to Interpret Level 2 Data

How to Interpret Level 2 Data

Level 2 data is important for traders because it shows the full range of open orders for a stock, not just the current best bid and ask price. Using Level 2 data, you can identify potential trades before they become apparent on technical charts or get additional...

Doji Candlestick Patterns

Doji Candlestick Patterns

A Doji is a type of candlestick pattern that often indicates a coming price reversal. This pattern consists of a single candlestick with a nearly identical open and close. In this guide, we’ll explain what the doji candlestick is and how traders can interpret it. How...

How Does Inflation Affect the Stock Market?

How Does Inflation Affect the Stock Market?

Inflation can have a big impact on the stock market, leaving unprepared investors in for a bumpy ride. In this article, we’ll explain why inflation impacts the stock market and take a closer look at how the stock market has reacted to inflation in the past. What is...

Ascending Triangle Chart Patterns

Ascending Triangle Chart Patterns

An ascending triangle chart pattern is a bullish technical pattern that typically signals the continuation of an uptrend. They can signal a coming bullish breakout above an area of resistance after it has been tested several times. In this guide, we’ll explain what...