Five Algorithmic Trading Strategies for the Stock Market
Here are five algorithmic trading strategies for the stock market.
Below, we outline the trading rules and provide equity charts.
All strategies have been backtested on the S&P 500 (SPY) from inception to the present, with 0.03% slippage and a per-trade commission.
We hope these examples inspire your own trading ideas. Remember to backtest any strategy yourself; this is not investment advice.
Strategy #1
In the first strategy, we aim to enter after the price has retreated from a recent high. We calculate a band using the 25-day average of the daily high–low range. A long trade is triggered when SPY closes below the 10-day high minus this band and the IBS indicator is below 0.3.
The exit rule is straightforward. To sell into strength and take advantage of mean reversion, we close the position when today’s close exceeds yesterday’s high.
We backtested the strategy in Amibroker, and an initial capital of 100,000 in 1993 has grown to nearly 2 million today. This represents an annualized return of 9.5%—slightly below buy-and-hold. But remember, the strategy is invested only 17% of the time.
With less time spent in the market, the maximum drawdown is much lower—23% compared to 55% for buy-and-hold. This leads to a strong risk-adjusted return of 53%, calculated by dividing the 9.5% annual return by the 17% of the time the strategy is invested.
Now, let’s move on to our second algorithmic strategy of the day and its trading rules.
Strategy #2
We buy the S&P 500 at the close on Monday if the market has closed lower for two consecutive days. We exit the position when the close rises above yesterday’s high.
Looking at the equity curve from 1993 to today, a 100,000 investment would have compounded at an annualized rate of 7.7%.
Strategy #3
Moving on to our third algorithmic trading strategy for the stock market: we enter a long position in the S&P 500 when the close falls below the lowest low of the previous five trading days and the IBS indicator finishes below 0.25. That’s all - just two simple rules. As before, we exit when the close exceeds yesterday’s high.
Starting with 100,000 in 1993, this strategy would have grown to 1.8 million today, even though it has been invested only 17% of the time.
Next is today’s fourth algorithmic strategy, which differs from the first three because it is based on a trading indicator.
Strategy #4
We use the DeMarker indicator to time buy signals. The DeMarker is an oscillator ranging between 0 and 100, signaling overbought and oversold conditions.
Using a 5-day lookback period, we enter a trade when the DeMarker indicator drops below 10 and exit when the close rises above yesterday’s high.
Backtesting on the S&P 500 shows a steadily upward-sloping equity curve. While there are a few minor setbacks, the overall performance is solid.
Strategy #5
Our fifth and final algorithmic trading strategy for the stock market is slightly different from the others.
Developed eight years ago, it has recently performed better than ever. The rules are simple: today’s high must exceed the highest high of the past ten days, and the IBS indicator must be below 0.15.
This strategy produced just 185 trades, with an average gain of 0.6% per trade. The average holding period was less than a week, and the annualized return was 3.2% - a modest figure due to being invested only 8% of the time. Despite that, it has the lowest drawdown at just 8%.
Combining All Five Strategies
Finally, we tested all five algorithmic trading strategies for the stock market together as a portfolio. We trade all strategies simultaneously, allocating 100% of equity to a single position and ignoring new buy signals if a trade is already open. Since all strategies share the same sell signal, there are no conflicts when exiting.
An initial investment of 100,000 in 1993 would have grown to 3.6 million today, demonstrating the power of compounding. Note that the equity chart uses a logarithmic scale, so relative changes are easier to see.
The combined portfolio had only two losing years.
Even better, during challenging years like 2008 and 2022, the strategies still gained 20.7% and 10%, respectively. Across 742 trades, the average gain was 0.5% per trade, translating into a compounded annual return of 11.5% - well above buy-and-hold - despite being invested only 32% of the time.
All 5 algorithmic trading strategies for the stock market were originally published years ago on our website; thus, we have many years of out-of-sample data.
Related reading: 5 mean reversion algorithmic trading strategies
PS! This is not investment advice. ALWAYS do your own due diligence. This is only meant to give you trading ideas you can backtest and improve yourself. Backtests are not live trading, and results might differ when you go live, especially due to emotions, execution, and slippage.
Thanks for reading our article about 5 algorithmic trading strategies for the stock market.



















