The stock market has always been a roller coaster ride, but this year has been particularly volatile. Earlier this year, the S&P 500 experienced its worst quarter since 2008. However, the market has rebounded over the last couple of months, and the S&P 500 recently recovered its losses and turned positive for the year.

Some experts say that another crash is looming, though, which could be devastating to investors who have already watched their portfolios plummet once this year. Some people may be tempted to avoid investing in stocks altogether for fear of losing money, while others may try to capitalize on an upcoming recession by investing more heavily in stocks.

There is a possibility of playing it too safe or too risky. During times of market volatility, it's especially important to make sure you're not investing too much (or too little) in stocks.

Couple looking at phone and documents

Image source: Getty Images

Finding the right balance

Your portfolio is likely made up of a variety of investments, with some riskier (like stocks) and others more conservative (like bonds). Stocks experience higher rates of return than bonds over time, but they're also more susceptible to volatile ups and downs. Bonds, though less risky, grow much slower, making it more difficult to build wealth.

If you're worried about another market crash, you may be tempted to pull most of your money away from stocks and put it toward bonds instead. While that may protect your savings in the short term, you'll eventually need to continue investing in stocks if you want to see long-term growth. And because timing the market is next to impossible, it will be incredibly difficult to know when to sell your stocks and then start buying again. For that reason, it's best to avoid shifting your investments around too much in an attempt to buy or sell at just the right time.

But it is a good idea to gradually adjust your investments as you get older. When you're relatively young and still have plenty of time before you stop working, your retirement fund should be made up mostly of stocks so that your investments can grow substantially. There's more risk involved in investing primarily in stocks, but your money also has years to recover from any market crashes.

Then as you get older, your investment portfolio should shift toward more conservative investments like bonds. The closer you get to retirement age, the more conservative your portfolio should be. You'll still want a small portion of your portfolio to be allocated to stocks so that your investments can continue to grow even after you retire.

Adjusting your stock investments to limit your risk

As you get older, your investments should lean less toward stocks and more toward bonds. But it can be tough to figure out when you should make these adjustments and just how much you should be investing in bonds versus stocks. This is where target-date funds can make investing a whole lot easier.

Target-date funds automatically adjust your investments as you get older. You simply have to choose your target date (or the age you plan to retire), and the fund will ensure that your investments are getting more conservative the closer you get to that date. In other words, target-date funds are essentially "set it and forget it" types of investments that will help you limit your risk while taking a hands-off approach.

One downside to target-date funds is that they can be more expensive than other types of investments. Higher fees will take a bigger bite out of your earnings, and those fees add up over time. Although they may charge higher fees, target-date funds are still one of the best ways to ensure your investments are allocated properly.

Investing in the stock market can be intimidating, but it's one of the most effective ways to build long-term wealth. Just be sure you're investing your money in the right places to avoid as much risk as possible.