The S&P 500 (^GSPC 0.14%) advanced 24.2% in 2023 as signs of economic resilience made investors increasingly confident in a soft landing, a scenario in which the Federal Reserve successfully brings inflation under control without causing a recession.

That momentum has spilled into 2024. The S&P 500 advanced another 10.2% during the three-month period that ended in March, its second-strongest first-quarter performance of the past decade. Even more impressive, the index has already hit 22 record highs this year, according to Goldman Sachs, and it sits within striking distance of another.

Here are the two worst mistakes investors can make right now.

Mistake 1: Avoiding the stock market or selling stocks without good reason

Isaac Newton once said, "What goes up, must come down." That axiomatic statement is irrefutable where gravity is concerned, but investors should never apply that logic to the financial world. The stock market is not obligated to decline after moving higher.

In fact, investing in the S&P 500 at its peak has historically been a smart decision. Strategists at JPMorgan Chase recently wrote, "Over the last 50-odd years (going back to 1970), if you invested in the S&P 500 at an all-time high, your investment would have been higher a year later 70% of the time, with an average return of 9.4% -- versus the 9% on average when investing at any time."

With that in mind, the worst mistake investors can make right now is avoiding the stock market or selling stocks simply because they are worried about a possible correction. To quote famous investor Peter Lynch, "Far more money has been lost by investors preparing for corrections, or trying to anticipate corrections, than has been lost in corrections themselves."

To be clear, I am not saying the stock market will definitely go up in the coming months. I am simply pointing out that market peaks are nothing to fear. More importantly, patient investors have historically done quite well. The S&P 500 returned 572% over the last two decades, compounding at 10% annually, despite suffering three bear markets and seven corrections.

Mistake 2: Falling prey to fear of missing out

There is a second mistake, no less dangerous than the first, that investors must avoid: falling prey to fear of missing out (FOMO). Even the most levelheaded investors can be tempted to ignore fundamentals and chase momentum when the stock market is soaring, but purchasing stocks without concern for price will eventually backfire.

The frenetic enthusiasm surrounding artificial intelligence (AI) is an excellent example. I believe AI will change the world in the coming decades, perhaps more so than any technology in human history. In fact, just as you and I take mobile phones and the internet for granted, I bet people in the future will consider self-driving cars and autonomous robots commonplace. But that does not mean every AI stock is a worthwhile investment.

More importantly, not even the best AI stock is worth buying at any price. Investors must always consider valuation when putting their money to work in the market. Warren Buffett commented on that topic in his 1982 letter to Berkshire Hathaway shareholders. "A too-high purchase price for the stock of an excellent company can undo the effects of a subsequent decade of favorable business developments," he wrote.

With that in mind, the S&P 500 currently trades at 20.5 times forward earnings, a significant premium to the 10-year average of 17.7 times forward earnings, according to FactSet Research. That means many stocks are trading at historically elevated valuations, so investors should be especially cautious in the current market environment. To quote Buffett, "Be fearful when others are greedy."

Here's the bottom line: The two worst mistakes investors can make right now are (1) avoiding the stock market or selling stocks without good reason, and (2) falling prey to fear of missing out. The S&P 500 has historically performed quite well from record highs, but not even the best stock is worth purchasing at any price. Investors should always consider valuation when buying stocks, and they should never buy a stock they aren't prepared to hold through a market downturn.