There's never a shortage of confident-sounding predictions about what's coming up for Wall Street, but no one ever knows for sure when the next market crash will hit. Indexes have soared so far in 2021, mainly thanks to surging spending by consumers and businesses. Those trends could quickly change, though, as they have several times since the pandemic struck in early 2020.

But if we can't be sure about their timing, we can be sure that downturns will happen at some point. They're inevitable. That said, jumping in and out of stocks is a poor strategy for hedging against that risk. 

Investors who try to time the market are likely to miss at least some of the rebound that follows a plunge, even if they guessed right about the timing of the downturn. You're better off buying and holding high-quality stocks that provide solid returns even through economic and market slumps.

With that objective in mind, let's look at why you might want to add Walmart (WMT 1.02%) and McDonald's (MCD 1.32%) to your portfolio today.

A man purchasing beer at a supermarket store.

Image source: Getty Images.

1. Walmart

Walmart's stock price hardly dropped at all during the pandemic-driven market collapse in March and April of 2020. Its shares even rose slightly as the S&P 500 dove by more than 20%.

^SPX Chart

Walmart share price from March 1, 2020, to Sept. 1, 2020. Data by YCharts

True, that outperformance can be credited to the period's unique selling environment, which featured the temporary closure of all nonessential retailers. But investors also found comfort in Walmart's dominance within the consumer staples industry and its stellar financial track record.

The bullish investment thesis has only improved since then. Walmart added $40 billion to its selling footprint in 2020, gaining millions of new customers through its digital and in-store channels.

Management boosted the stock's dividend for the 48th consecutive year, and the chain's gushing cash flow has allowed it to make aggressive bets in high-return areas like store remodels, e-commerce, and data monetization. But in 2021, the stock hasn't participated at all in the wider market's 20% surge, making it a good candidate for outsized returns during any pullback.

2. McDonald's

McDonald's stock swooned along with the wider market during the pandemic crash, which makes sense given that the fast-food titan had to close most of its dining rooms as social-distancing safety measures were implemented. Yet even a global operating pause hardly dented Mickey D's finances. Its operating margin briefly fell to roughly 37% of sales, comfortably above those of its industry peers. That's partly because the chain derives much of its earnings from stable sources like royalties, rent, and franchise fees.

MCD Operating Margin (TTM) Chart

MCD Operating Margin (TTM) data by YCharts

Over the past year, the company cut costs so that its franchisees can enjoy even higher cash returns. And McDonald's diversified its selling base by complementing its dominant drive-thru channel with a big push into home delivery.

Those assets, plus a dividend that has been growing for 40 consecutive years, should help the fast-food titan's stock sail through the next market downturn, especially given its relative underperformance so far in 2021.

Staying diverse

Stock market downturns occur relatively frequently, and full-blown crashes happen on occasion. While there is no sure-fire method for predicting the timing, scope, and severity of the next slump, investors can lower the risk it will pose to their holdings by owning shares of high-quality businesses with stable earnings and rising dividend payouts.

Wall Street has paid less attention to many of these stocks of late, instead focusing on companies with splashier growth opportunities in areas like cloud computing and e-commerce. But market pullbacks tend to shift investors' focus back toward perennial winners like McDonald's and Walmart.