Cover image created through Copilot
Ever wondered how to tell if the market is roaring like a bull or growling like a bear? This article will dive deep into how these indicators perform in different market conditions, comparing manual identification with indicator-based methods. By adding this market indicator, you’ll see how momentum strategies shine in bull markets, while mean reversion and pair trading strategies come into play during bear markets. Plus, we’ll uncover some insights that you might never have considered while applying market indicators in your own algorithm trading script. Now, let’s dive in and uncover the secrets of the market together!
Previous researches
- 【ML algo trading】One Pitfall You Definitely Need to Avoid in Feature Engineering
- 【How 2】A Productive Way to Manage OAuth 2.0 Tokens
- 【How 2】Breaking Free! Use Docker to Create Hands-Off Interactive Broker TWS Managing Experience
Context
Various quantitative trading strategies are currently executed in the market, and each strategy has its own characteristics and advantages. For example, momentum trading strategies are often used to profit from the trend of the bull/bear market, while mean reversion strategies are often used to profit from the fluctuation of the market; machine learning algorithms can be used to discover the hidden pattern in the market and to profit from it accordingly; pair trading strategies aim to exploit the short-term turmoil in the market and to make profit from the pricing adjustment movement among multiple correlated assets.
However, the market is not always in the same stable state, and various influences, macro or micro, could affect and change the market conditions. Therefore, executing one single trading strategy throughout the entire market cycle is not always the best choice. Hence, inventing a method to constantly detect and monitor market conditions has become an important topic in the quantitative trading field.
What is the Market Indicator?
Before we dive into the details of the market indicator, let’s first understand what the market looks like. Below is the SPY index market return n from 2020-01-03 to 2024-09-16:
The SPY market return from 2020-01-03 to 2024-09-16
As the first step to decide what kind of trading strategy we’re using, we would need to visually identify what is the market condition now. I believe most of the investors like me would classify the market as below:
Identified bull/bear market conditions
What is the purpose of a market indicator? In essence, it is a quantitative, mathematical, and analytical tool that allows algorithms to assess current market conditions without the need for human intervention. By accurately identifying the existing market situation, investors can implement trading strategies that are best suited to the current climate, maximizing the performance of their strategies.
In this post, I’m going to introduce the following four basic market indicators that help the investor to identify the market condition and to make the trading strategy more robust.
Using SPY daily close price and its history data
- SPY index stands for the S&P 500 index, which is a market-weighted index of 500 large-cap U.S. stocks. Therefore, we can use the 200-day Simple Moving Average of SPY close price as a threshold. When the SPY daily close price is above the 200-day Simple Moving Average, the market is considered to be bullish; otherwise, it is considered to be bearish.
The Average Directional Indicator (ADX)
- The ADX is a technical indicator that measures the strength of a trend. It is calculated by comparing the difference between the current high and low prices with the previous high and low prices. To see more details of ADX, you can refer to this and this article.
- In the book Quantitative Trading Strategy (by LARS KESTNER), he mentioned that the 14-day ADX is a good indicator to identify the market condition, and recommends the following frameworks to identify the market condition:
Regime | Trend | Strategy |
---|---|---|
ADX < 15 | Mean reverting prices | RSI oscillator to take counter-trend signals |
15 < ADX < 25 | Random walk, no trend, no mean reversion in prices | No trading |
ADX > 25 | Trending prices | 40-day/20-day channel breakout |
Regime switching rule I
Regime | Trend | Strategy |
---|---|---|
ADX < 20 | Trend to begin soon | 40-day/20-day channel breakout |
20 < ADX < 30 | Mean reversion in prices | 14 day RSI strategy |
ADX > 30 | Trending prices | 40-day/20-day channel breakout |
Regime switching rule II
CBOE VIX Index
- The VIX index is a measure of the market’s expectation of future volatility based on S&P 500 index options. The VIX index goes high when the market is volatile and low when the market is stable. So we will use the 15-day VIX SMA plus 15% of it as a threshold. When the VIX index close price is above the threshold, the market is considered to be volatile/bearish; otherwise, it is considered to be stable/bullish.
Yield Curve Inversion
- I assume most of you have been quite familiar with this indicator. The yield curve inversion is a situation where long-term interest rates are lower than short-term interest rates. This situation is considered to be a sign of an impending recession. Therefore, we will use the 10-year Treasury yield and the 2-year Treasury yield as indicators. When the short-term yield curve is above the long-term yield curve, we consider the yield curve inversion is happening, and the market is considered to be bearish and vice versa. Here is the definition of the yield curve inversion if you want to know more.
Backtest Results
Platform
Backtest Period
2020-01-03
to 2024-09-16
Trading Framework
Universe
The constituents of the SPDR S&P 500 ETF Trust (SPY)
Strategy Benchmark
SPDR S&P 500 ETF Trust (SPY)
Trading Rules
- First of all, we need to prepare two strategies: one is the momentum trading strategy that can capture the momentum when the market is bullish, and the other is the mean reversion trading strategy that can capture the momentum when the market is bearish. I’ve created a weekly rebalancing momentum strategy and a RSI reverse trading strategy to be executed when the market is bearish. Unfortunately, my bullish and bearish trading strategies are highly correlated, which makes it less likely to compensate when the momentum is diminished. Therefore, I’ve decided to use the cash strategy to hold cash only when the market is bearish. You can replace it with investing in other fixed-income securities.
Strategy performance correlation heatmap
- For each trading strategy, we design the capacity to hold ten stocks maximum.
- All the positions are created or closed right after the market opens.
- Strategy-specific trading rules
- Momentum trading strategy
- Calculate the momentum of each stock by averaging the one-month, three-month, six-month, and one-year returns evenly.
- Rebalance the portfolio by holding the top 10 stocks that have the highest momentum scores.
- Cash holding strategy
- Liquidate all the positions and hold cash only.
- Momentum trading strategy
- According to the market condition detected by the market indicator, we will switch the trading strategy to momentum trading strategy when bullish, while switching to the cash holding strategy when bearish.
One thing that I’ve noticed while conducting this backtest and would like to share with you is that there’s a situation that you need to be aware of. You might encounter the scene where you will need to switch to another trading strategy while having positions open in your portfolio. To further manage your assets, you could do the following to make sure the trading strategy executes the exact instructions you expected:
- Liquidate all the opening positions before you long the new assets from another trading strategy.
- Hold the current positions and apply the exit rules of the new trading strategy.
- Use the market indicator that is more robust to minimize the number of times you need to switch the trading strategy.
Let me know if you have any other better ideas to handle this situation.
Benchmark performance of the strategy (momentum only)
Below is the backtest result of the momentum strategy performance. As you can see, the strategy performance dropped significantly during February 2020 and stayed relatively flat from November 2021 until 2023 September. We expect to increase the return in these periods by incorporating the market indicator and to switch to the cash holding strategy to reduce the loss and increase the overall return.
Momentum strategy performance backtest results
Results (attached with the strategy switching plot)
Using SPY daily close price and its history data
Strategy performance when adopting SPY as a market indicator
The first plot above shows the performance of the strategy. The second plot indicates what strategy was used according to the SPY market indicator. The bottom plot is to plot the SPY daily close price and its 200-day moving average. As said when the daily close price soar above the 200-day moving average, the momentum strategy is used. Otherwise, the cash holding strategy is used.
Now let’s go back to the first plot. The red line marked the clear bear market seems pretty conforming to the grey dotted line, which indicates the perceived bear market. However, once you look closely and compare it to the original benchmark strategy performance, you will find out that this strategy missed the comeback of the market from the bottom. Even though the SPY market indicator did help us cap the loss, missing the comeback of the market greatly damaged the profitability of the strategy. If the SPY indicator can increase the sensitivity on the part to detect the market recovery earlier, the strategy could be more profitable.
The SPY market indicator results in 32 changes between trading strategies. This high frequency of changes leads to frequent trading, incurring significant transaction costs and very short holding periods. Both these outcomes are often not beneficial and could be toxic if you can’t manage them well in the trading strategy. By smoothing the market indicator and reducing the frequency of strategy adjustments, we can minimize friction. This approach will decrease the incidence of short-term, unnecessary trades, thereby lowering transaction costs and enhancing the overall performance of the strategy.
Average Directional Indicator (ADX)
Let’s recap the trading rules of the strategies using ADX as the market indicator.
ADX Trading Rule One
Regime | Trend | Strategy |
---|---|---|
ADX < 15 | Mean reverting prices | RSI oscillator to take counter-trend signals |
15 < ADX < 25 | Random walk, no trend, no mean reversion in prices | No trading |
ADX > 25 | Trending prices | 40-day/20-day channel breakout |
Regime switching rule I
The basic idea of this is to execute the momentum strategy when the ADX market indicator detect the bull market, execute the cash holding strategy when the fluctuating market is detected, and execute the mean reversion strategy to capture the reversion of the market during the bear market. At first hearing, the core method of the trading strategy sounds legit. However, you see the different strategies got switched as many as 73 times from the second plot in the strategy backtest results below. The idea to introduce the market indicator is to identify not just the current market state but also the beginning of the future market trend. Given the volatile market state predicted, switching the trading strategy too frequently diminished the effectiveness of all trading strategies.
Strategy performance when adopting ADX rule 1 as a market indicator
ADX Trading Rule Two
Regime | Trend | Strategy |
---|---|---|
ADX < 20 | Trend to begin soon | 40-day/20-day channel breakout |
20 < ADX < 30 | Mean reversion in prices | 14 day RSI strategy |
ADX > 30 | Trending prices | 40-day/20-day channel breakout |
Regime switching rule II
To improve the previous trading strategy, LARS KESTNER in his book Quantitative Trading Strategy recommended a different regime switching rule. In this new rule, he proposed treating the bull and bear market in the same condition and leaving the fluctuating market as a separate condition. We execute a momentum trading strategy not only during bull but also bear market, while executing the mean reversion strategy during the fluctuating market.
Strategy performance when adopting ADX rule 2 as a market indicator
Surprisingly, even though the backtest results were not as satisfactory, there are a few noteworthy points:
- We expected fewer strategy switches. However, the strategy still switched 83 times, which is more than the previous rule.
- Despite the increased frequency of strategy switches, the actual number of trades was significantly lower than with the previous rule.
- Upon cross-checking the order history and the timing of strategy changes, I discovered that when the strategy switched from a bull to a bear market, the signals from both trading strategies pointed to the same stock symbols. This indicates that the stocks with the greatest momentum in a bull market tend to be the same stocks that experience the greatest dip when the market turns bearish. This could be an interesting finding to explore further.
Anyway, in general, the ADX indicator seems too volatile to be used as a market indicator and needs more investigation.
CBOE VIX Index
Compared to other market indicators, the CBOE VIX Index behaves somewhat differently. As a measure of the implied volatility of S&P 500 index options, the VIX can spike dramatically in a short period. When the market and investors recognize heightened volatility, the VIX tends to decrease swiftly as the negative sentiment has been absorbed by the market and other financial institutions.
As illustrated in the chart below, the frequent spikes indicate that the VIX primarily measures market sentiment and tends to return to a stable state quickly.
VIX daily price captured from Yahoo! Finance
The chart below shows that the strategy adopting VIX as market indicator has a very nice performance close to the benchmark trading strategy. The performance of the strategy has nearly no growth from February 2021 to January 2024, meaning this strategy took around three years to recover from the bottom. On the other hand, if you look at this from another perspective, adding the VIX market indicator to the trading strategy has helped reduce the volatility, and also the max drawdown, from 42% to 26%, giving a similar profitability, 20.193% vs 17.137% annually. Therefore, it’s quite clear that VIX does help detect the beginning of the bear market and further avoid the significant loss effectively.
Strategy performance while adopting VIX as a market indicator
Strategy | Sharpe Ratio | Total Return | Annual Return | Max Drawdown | Annual Variance |
---|---|---|---|---|---|
Benchmark | 20.012 | 137.07% | 20.193% | 41.9% | 0.051 |
VIX | 16.462 | 110.81% | 17.137% | 26.00% | 0.042 |
Comparison of the performance between VIX market indicator strategy and benchmark strategy
Yield Curve Inversion
As known, the inversion of the yield curve is widely regarded as a signal confirming a recession of the macroeconomics. The primary indicators used are usually focusing on the spread between 3-month and 10-year treasury yield. The backtest result is as below:
Strategy performance using 3-month and 10-year yield curve as indicators
Surprisingly, unlike previous market indicators, the yield curve inversion using the 3-month and 10-year treasury yields marks the market into two distinct states. The first half of the backtest period shows a bull market until early 2022, while the second half indicates a bear market. However, when comparing the strategy performance plots with the trading strategy used, the stock market trend doesn’t positively correlate with our bear market prediction. We stopped investing during the market turmoil around November 2022, but the market indicator didn’t turn bullish during the subsequent stock market rise. So, to increase the sensitivity of the yield curve market indicator, let’s try using 3-month and 2-year treasury yields to mark the market.
Strategy performance using 3-month and 2-year yield curve as indicators
The movement of both the 3-month and 2-year treasury yields is more pronounced and clearer than in our previous backtest. However, the new backtest doesn’t reveal any advantage of using the more sensitive market indicator. While the strategy’s performance does improve, there is no evidence of improvement in the max drawdown, annual variance, or standard deviation.
Strategy | Sharpe Ratio | Total Return | Annual Return | Max Drawdown | Annual Variance | Standard Deviation |
---|---|---|---|---|---|---|
3-month vs. 10-year | 0.424 | 77.30% | 12.899% | 28.40% | 0.039 | 0.197 |
3-month vs. 2-year | 0.473 | 89.69% | 14.466% | 30.40% | 0.04 | 0.201 |
Comparison of the performance between strategies 3m-10y and 3m-26 yield curve
Conclusion
After all the backtests and their plots clearly illustrated above, we can briefly summarize the following conclusion of these four market indicators:
- SPY market indicator does seem to possess the capability to mark the bullish/bearish market. Even though the timing wouldn’t 100% overlap between the market state predicted and the market state we visually marked, the SPY market indicator helps separate the market into a clear bullish and bearish market.
- ADX market indicator seems to be too volatile to distinguish the bullish market from the bearish market. This approach would need a method to smooth the fluctuations before applying to any strategy.
- VIX market indicator doesn’t seem to belong to the same arena as other market indicators. Given the characteristics of short-term fluctuations of the CBOE VIX, it could be used as a stop gain/loss signal rather than a market indicator.
- Yield curve inversion market indicator is the most stable market indicator that separates the bullish from the bearish. However, it wouldn’t be able to reflect the coming back of the stock market swiftly.
I guess finding an ultimate market indicator would be the topic that all individual and institutional investors are trying to discover. It’s like a hidden holy grail that everyone craves. So understanding these four basic market indicators, it would just be the start of the long journey to the holy grail.