Investors felt great after gains of over 20% apiece for both the S&P 500 and Nasdaq in 2021, but the mood has shifted in 2022 as these indexes have fallen 21% and 33% year to date, respectively. While this is discouraging, investors can also take solace in the fact that bear markets are temporary in nature and that they create a buying opportunity to accumulate more shares of great companies at discounted prices. Legendary investor Shelby Davis once commented on this, explaining that "A down market lets you buy more shares in great companies at favorable prices. If you know what you're doing, you'll make most of your money from these periods. You just won't realize it until much later."

Remember that buying a stock isn't just buying a name on a screen -- you are acquiring a piece of a publicly traded company that entitles you to a portion of its earnings and cash flows, and a down market gives you the opportunity to buy more of the company at a cheaper price. So while it might not feel great at the moment, a bear market is a good time to build up positions in long-term winners that have sold off. With shares down 32.5% year to date, home improvement retail giant Home Depot (HD 0.02%) is a good example of a great company that you can buy now at a favorable price to turn the market slump into a solid long-term opportunity.

Two people measure a piece of wood to cut for a home improvement project.

Image source: Getty Images.

Shrugging off the doom and gloom 

Shares of Home Depot have lost nearly a third of their value this year because investors are worried that rising mortgage rates will curtail demand in the housing market, and a weak macro economy might also make customers put off large home improvement projects. But all of the macroeconomic doom and gloom doesn't appear to be slowing down Home Depot's results -- in fact, the company reported its highest-ever quarterly sales and earnings numbers during the most recent quarter. In Q2, the blue chip company increased revenue by 6.5% to $43.8 billion year over year, while increasing earnings per diluted share by 11.5% over the same period to $5.05.

It's also possible that rising mortgage rates and slowing home sales might not be as bad for Home Depot as many people think -- if homeowners decide not to move because they don't want to give up their current mortgage rate for a much higher one, they could be more likely to stay put and to allocate some money toward improving the home that they are currently in. On the company's second-quarter earnings call,  CEO Ted Decker commented that the company saw growth from both its Pro (professional contractor) and DIY (do-it-yourself) customers during the quarter and that Home Depot is "encouraged that project backlogs remain healthy."

Home Depot is a long-term winner

Home Depot has been around for a long time and it has proven to be a long-term winner that can roll with the punches -- the stock is up nearly 79,000% since its 1978 IPO, and more recently, Home Depot has given its investors an incredible return of over 350% over the past decade. Patient investors can look at this year's sell-off as a speed bump on a much longer road of value creation.

After this year's sell-off, shares of Home Depot now trade at about 17.5 times earnings, putting this blue chip stock on par with the broader market's valuation. This also means that the stock is now trading at a discount compared to its historic valuation -- over the past decade, Home Depot has traded at a trailing-10-year multiple of 23 times earnings.

In addition to its long-term history of value creation and reasonable valuation, Home Depot is also a steady dividend stock that has been paying a quarterly dividend for 35 years, dating back to 1987. While the stock is not a Dividend Aristocrat because it didn't increase its annual payout during 2000 or 2008, it has been a reliable dividend payer for many years, and its current dividend yield of 2.7% is well above the market average.

Between its above-average dividend yield, cheaper-than-historic multiple, and increasing earnings, Home Depot should be able to provide investors who are willing to buy shares during the current market slump with solid returns going forward.