With the stock market recently closing at its highest level ever,  investors might be getting a little nervous that another crash is coming. Because of those nerves, they may be questioning whether now could be the right time to start building a cash position.

That raises a good question. Should investors be stashing cash right now? That's an easy question to ask -- and a somewhat tougher one to answer. The short version of an answer is that every investor should always have some cash available, and if you don't, then a market high is a great time to raise a bit of it. Still, whether you should be stashing cash right now depends as much on your personal financial situation as it does on the current state of the market.

Woman holding cash and smiling.

Image source: Getty Images.

Why you need some cash

If something unexpected were to happen to you where you needed cash in a hurry -- say a car wreck, an injury, or a job loss -- how would you get hold of that cash?

If your answer is "I'd sell some stocks", then you've got a problem. Because what happens if your stocks happen to be down when you needed to sell them? Your bills aren't going away, after all.

You'd have to sell more shares to raise the same amount of cash, assuming you could even sell enough shares to raise what you need. That would mean you'd have that much less invested to take advantage of any subsequent recovery that happens.

By having a decent emergency fund in cash, you don't have to worry about what the market is doing when you need to raise your cash. You'd already have it available. As a general rule of thumb, you'd want to keep around three to six months of your expenses in an emergency fund. If you're not at that level yet, then the market being near an all-time high is as good a reason as any to raise some cash to get there.

Similarly, if you are expecting to cover costs from your portfolio within the next five years, you should make plans to get that money in something with higher certainty than stocks. Cash works for that purpose, but so do duration-matched CDs, Treasuries, or potentially even investment-grade bonds. This is for the same reason you don't want to own stocks to cover your emergencies -- when you need the money, you don't want to be forced into selling your stocks when they're down.

Why else might you want to raise cash?

Beyond those fundamental personal financial reasons, if the market's rise has given you a gift, it's perfectly OK to accept it. If an investment you own has skyrocketed past any semblance of its fair value, then holding cash might very well be a preferable alternative to continuing to own its shares. Similarly, if it has grown to be too large a portion of your holdings for your comfort zone, then selling a bit and holding cash can be a worthwhile use of your gains as well.

Additionally, if you're investing for a key purpose -- such as your kids' educations -- and the market's recent gains have given you enough to reach that goal, then it's OK to sell. Congratulations, you've accomplished what you set out to accomplish. Why take financial risks you don't need to take? Celebrate your success, take the money you need to cover that cost, and enjoy the added freedom that comes from not having to worry about that particular objective anymore.

Finally, there's nothing wrong with taking advantage of the market's generosity and splurging a bit on yourself or your family or in donating a bit to charity if you're so inclined. Just recognize that the market's moods are fickle, and today's gains could turn into tomorrow's losses. As such, make sure you're not taking on ongoing expenses based on what might only be one-time gains. Think in terms of things like a spectacular vacation or a one-time major gift.

So why stay invested?

The reasons to raise cash shared above are tremendously strong ones. If any of them apply to you, by all means, go ahead and convert some shares into cash and enjoy the benefits that come from the improved liquidity you have.

If, on the other hand, you're just nervous because the market is up, you might want to think again before raising cash. Over the long haul, the market has provided investors with solid total returns from compounding of both growth and dividends. That growth over time means the market has regularly hit new highs in the past -- and continued to grow after hitting them.

So don't let the mere fact that the market is up drive you away from owning the stocks of great companies with strong long-term growth potential. Instead, evaluate those businesses based on their prospects and current market values. If the stocks' recent gains simply mean that the market is finally beginning to recognize those business' true potential, then you would likely be doing yourself a favor by continuing to hold.

Now is a great time to figure out what cash you need

Regardless of what you end up doing, a new high in the market does give you a great opportunity to evaluate where your cash position is compared with what you really need it to be. If it turns out you do need more cash, you'll be able to get away with selling fewer shares than you would have before at a lower price. If, on the other hand, it turns out that you've got the cash you need, then that's a good thing, too. It should help boost your confidence to ride out any market volatility.

So take advantage of the market's recent rise to consider whether your cash reserves are where you need them to be. If you let that drive your actions, you'll likely find yourself better prepared to handle whatever the market does next.