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

Best Technical Indicators for Day Trading

Best Technical Indicators for Day Trading

Technical indicators play an important role in trading, and particularly in day trading. Indicators provide deeper insight into price movements and give traders the information they need to identify potential setups and make trading decisions. While there are hundreds...

Risk/Reward in Trading

Risk/Reward in Trading

Learning to manage risk effectively is key to success as a trader. Good risk management helps minimize your losses and preserves the gains from your winning trades. By understanding the risk/reward ratio of any individual trade, you can better decide which setups to...

Quadruple Witching Guide

Quadruple Witching Guide

Quadruple witching is a market day when single stock options, stock index options, single stock futures, and stock index futures all expire. Quadruple witching days typically see above-average trading volume, although this volume isn’t necessarily accompanied by...

What are Iceberg Orders?

What are Iceberg Orders?

Iceberg orders are a type of trade typically placed by institutional investors. They are designed to mask the size of an order, such that only a small portion of the total trade – the tip of the iceberg – is visible to the market. Traders who can recognize iceberg...

What is a Gap Fill in Stocks?

What is a Gap Fill in Stocks?

Gaps in a stock chart occur when the price of a stock moves suddenly up or down, usually in response to news outside of market hours. In some cases, these gaps don’t last – rather, they’re “filled” as trading action brings the price back towards the previous close....

Why Do Stocks Get Halted?

Why Do Stocks Get Halted?

Trading halts can be a big deal for active investors, particularly if you are holding a stock that temporarily can’t be traded. But since trading halts are relatively rare, many traders don’t know why they happen or how they work. In this guide, we’ll explain why...