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. 


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

Market Makers vs. ECNs

Market Makers vs. ECNs

Introduction When you place an order to trade stocks, there are typically two ways in which it can be processed: by a market maker or by an electronic communications network (ECN). Market makers and ECNs are critical for keeping the market running smoothly and play...

Inverse Head and Shoulders Pattern: The Complete Guide

In this article, we'll be detailing the inverse version of the well-known head and shoulders chart pattern so you can start effectively incorporating it into your trading. An inverse head and shoulders pattern is a technical analysis pattern that signals a potential...

Float Rotation – What It Is and Why it Matters

Float Rotation – What It Is and Why it Matters

Float rotation describes the number of times that a stock’s floating shares turn over in a single trading day. For day traders who focus on low-float stocks, float rotation is an important factor to watch when volatility spikes. In this guide, we’ll explain what float...

Level 1 vs. Level 2 Market Data

Level 1 vs. Level 2 Market Data

Successful trading relies on having good information about the market for a stock. Price information is often visualized through technical charts, but traders can also benefit from data about the outstanding orders for a stock. This type of data is known as Level 1...

What is a Shelf Offering?

What is a Shelf Offering?

Have you ever seen a stock exhibiting normal trading behavior and then all of a sudden the stock price drastically drops out of nowhere? This type of price action could be related to the announcement of a shelf offering or the execution of an “at-the-market” sale from...

How to Recognize a Short Squeeze

How to Recognize a Short Squeeze

Short squeezes can introduce a lot of volatility into stocks and send share prices sharply higher. These squeezes offer opportunities for trading, but they often require different strategies and more caution than traditional breakouts. In this article, we’ll take a...