Algorithms for Trading
The hardest part of starting any project, including building a quantitative trading strategy, is figuring out where to start. To that end, this post covers a basic overview of a few algorithms for trading. We hope to help you get your creative energy to level up.
Interday Momentum Strategies also called Trend Following Strategies
Interday momentum strategies utilize statistical analysis of a series of market data in standard sets of time slices. In determining when to buy or sell a stock the algo developer will seek out favorable trends and deviations from those trends. Orders are placed when a favorable trend is found, or when a favorable change in trend occurs. Positions are closed for a profit or loss when the momentum no longer exists or a maximum stop loss event occurs.
Some examples of momentum algorithms are:
- Buying to enter an uptrend
- Short Selling to enter a downtrend
- Buying when sideways trend is at a low point
- Short Selling when a sideways trend is at a high point
- The time sliced market data cannot vary in size otherwise it distorts the analysis.
Trading Range sometimes called Mean Reversion
Many stocks trade a standard range. If all things remain equal, the stock will follow the same pattern and stay in a predictable range. Any high or low price at the edges of the standard range being a momentary discrepancy that can be exploited for profit. Orders are placed when a price discrepancy outside of the standard range is found. Positions are closed for a profit when the price returns to normalcy.
- All things rarely remain equal.
Pairs Trading Strategies
Two stocks tend to trade in similar patterns. Historical analysis will show that for some logical or illogical reason the two stocks tend to follow one another up and down over time. The stocks correlate. Any time that the price of one deviates from a formula then the other stock is almost certain to follow. This is the theory behind pairs trading. In the algorithm for trading it is dependent upon the data scientist to figure out the pairs and the strength of the correlation.
Orders (for both stock) are placed when the standard price correlation changes. Positions (in both stocks) are closed for a profit when the price returns to normalcy.
- Regular review of price correlations is required.
Pattern Analysis Strategies also called Technical Indicators
Technical analysis is predicting, or forecasting, the direction of the stock price through the study of past behavior of the stock market prices and trades.
Technical algorithms look for patterns in the data that typically can be visually seen in the market data charts.
The primary operating concept is that the market is fundamentally efficient and that all information about the stock is properly interpreted by the traders and is perfectly reflected in the price that someone is willing to sell or purchase the stock.
The second operating concept is that the market moves predictably. The patterns seen in any stock’s price movement may be seen in another stock.
Orders are placed when a pattern is recognized that statistically will indicate that the price is going to move predictably. Positions are closed for a profit when the price reaches a target profit or when a maximum target loss occurs.
- You aren’t the only one watching for well documented patterns.
The Importance of Backtesting Your Algorithms for Trading
All these algorithms for trading have history worked. They are still traded today. The difference between profitably trading these algos and losing money is in the implementation. The process of reviewing your algorithm for trading against historical data is called backtesting.
Backtesting is the procedure of reviewing a trading strategy over a period of time and simulating profits and losses as if trading for real. CloudQuant’s products provide a robust backtesting environment that has proven historically accurate in determining the performance of algorithms for trading.
Backtesting isn’t a single event. A typical algo developer, or data scientist, will run numerous backtests each with changes to variables to determine which settings and which patterns work best.