Times have been tough for just about everyone this year. Inflation has hurt companies' earnings and consumers' wallets. Worries about the economy have made the situation even worse. Major indexes have dropped in the double digits. The S&P 500 Index even posted its worst first half since 1970.

But this doesn't mean we should stop investing in stocks. In fact, now is a great time to add to positions or discover new-to-us companies. Before getting started, though, let's look at three things the smartest investors are doing right now. And let's follow their lead.

1. Taking a long-term view

What's one of the major keys to investment success? Taking a long-term view. That means considering where a particular company will be at least five years down the road -- and investing if the outlook is bright.

In good times, it's easy to focus on the long term. But when times are tough, it's very tempting to panic when you see one of your favorite stocks declining at the speed of light. You might forget about the long-term picture. And your first instinct may be to sell, even at a loss.

But before you do that, hold on. If you believe in the company's ability to grow revenue and profit over a period of years, there's still plenty of time for that to happen -- and for you to benefit as a shareholder.

Stock price declines this year could transform into big gains in the coming years. That's because the current economic situation is temporary. It may hurt your favorite companies right now. But if their businesses are solid, they should recover and flourish.

This doesn't mean every company will recover, though. Taking a long-term view will help you identify potential winners and potential losers and make the best investment decisions.

2. Looking for two types of companies

Two types of companies stand out right now. I'm talking about those that are showing signs of recovery and those that have defied the crisis. Here are a couple of examples.

Amazon (AMZN -2.22%) has struggled with rising inflation and supply chain issues. Its usually stellar earnings reports started to sour as of late last year. But in the latest report, the e-commerce giant says it's making progress on controlling costs and improving productivity across its fulfillment network.

Recovery may not happen overnight. But Amazon is on the right path. At the same time, the stock is trading at less than three times sales. That's its lowest level by that measure in four years.

AMZN PS Ratio Chart.

AMZN PS Ratio data by YCharts.

Home Depot (HD -0.22%) shares have slipped this year. But from an earnings perspective, it's resisted the crisis. The world's biggest home repair retailer reported its best quarterly revenue and earnings ever in the second quarter. And for good reason. The demand for home repair supplies remains high.

Why buy these sorts of companies now? They could be among the first stocks to rebound as the market recovers. Even better, they may offer solid long-term potential. That's because they've demonstrated an ability to manage during tough times.

3. Maintaining an opportunity fund

It's wise to set aside some cash for future stock purchases. Even if the market recovers, certain individual stocks may decline -- and on some occasions, it may be a good time to invest.

You also may catch certain stocks on their way up as the market rallies. Buying opportunities can happen at any time. Not just when a stock is falling.

The size of your opportunity fund depends on your personal financial situation. In any case, this fund doesn't have to be huge. Today and in the future, it's possible to find promising stocks at just about any price. What's most important is to have the funds you need available so that you won't miss out on the next great investment.