Many investors probably look at a stock chart and envision buying at the bottom and selling at the top.

For example, you might imagine investing in the S&P 500 (^GSPC -0.30%) on March 9, 2009, when it bottomed out during the Great Recession, or when it hit its low after a plunge early in the coronavirus pandemic, on March 23, 2020. If you're looking at an individual stock chart, the opportunity can become even more mouthwatering.

However, in reality, investing isn't like this. You don't know where a stock will go in the future, and no one knows when a stock is hitting a bottom or a top.

Trying to buy a stock at the bottom or sell at the top is known as "timing the market," and it's impossible to do consistently. Warren Buffett, the Berkshire Hathaway founder and CEO, has said that trying to time the market is a waste of effort and that the stock market is a device for transferring money from the impatient to the patient.

A magnifying glass over the words "Market data" in the newspaper.

Image source: Getty Images.

Why patience wins in the stock market

The S&P 500 has an incredible track record of generating wealth, but you can only overcome the volatility inherent in the stock market by investing over the long term.

Historically, the S&P 500 generates an average annual return of 9%, but over a shorter period of time, stocks can do much worse. For example, the 2000s are often considered a lost decade in the stock market, as the S&P 500 was essentially flat from its peak in 2000 to 2013 due to the dot-com bust and the Great Financial Crisis.

Since then, the index has surged, ultimately rewarding investors who endured those twin crashes.

Overall, staying invested can help smooth out the volatility that occurs over short-term periods. It also avoids the need to decide when to get back into the market if you sell, which can be much more difficult than simply looking at a stock chart and buying at the bottom.