Many experts think the stock market has gotten a little too expensive, and in a historical context, they're absolutely right. By several metrics, the stock market is as expensive as it's ever been.

However, this doesn't necessarily mean that the next recession or stock market crash is right around the corner. It will happen eventually, but the market could easily have a few more strong years before it does.

For this reason, it can be a smart idea to start thinking a little defensively, but you also want to make sure you aren't putting yourself in a position in which you'll miss out if the bull market carries on for a while. With that in mind, here's a defensive investing playbook of three smart ways to set yourself up for whatever the stock market does next without missing out on potential upside.

Stock chart with upward trajectory.

The stock market won't go straight up forever, so it can be smart to prepare for whatever comes next. Image Source: Getty Images.

Focus on defensive stocks

As I'll discuss more later, it's a bad idea to sell your stocks simply because the market looks expensive. However, it can be a good idea to focus on defensive stocks when you're figuring out how to deploy new capital.

By "defensive stocks," I mean businesses that should do just fine no matter what the economy does. Walmart (NYSE:WMT) is an example that immediately comes to mind. During booming economic times, Walmart's customers have more money to spend, but during bad times, Walmart gets an influx of new customers who are trying to scale back expenses. In fact, during the Great Recession, Walmart's sales actually grew.

High-dividend stocks such as telecoms, utilities, and REITs are also good examples. Not only are these evergreen businesses, but stocks with reliable, above-average dividend yields tend to outperform their nondividend counterparts during tough times.

Average in to new positions

Dollar-cost averaging is a great way to buy stocks, but it makes particularly good sense if you think the stocks you want to buy might be getting a little overheated.

You can read our thorough dollar-cost averaging guide, but the basic idea is that instead of investing all at once, you invest a set dollar amount at a specific time interval in order to build a position over time.

For example, let's say that you want to invest $10,000 in Microsoft (NASDAQ:MSFT), which is trading for about $115 as of this writing. Instead of investing all $10,000 now, you could invest $2,500 at the end of each quarter over the course of the next year.

Without getting too deep into the mathematics, this strategy guarantees you a favorable average entry price. And if the market does indeed drop, this can allow you to buy at least some of your position at the new lower prices.

Keep some cash on the sidelines

Generally speaking, I suggest having most of your portfolio invested at all times.

Having said that, if the market looks expensive and you're having trouble finding attractive investment opportunities, it isn't a bad idea to start accumulating a little more cash than usual in your portfolio. As a personal example, I generally keep about 5% of my portfolio in cash with the other 95% invested in a diverse assortment of stocks. Recently, that cash figure has crept up to closer to 10%. I haven't sold any of my long-term stock investments -- I simply haven't invested my new account contributions recently.

Here's the point. If a stock market crash or correction occurs, you'll want some money available to take advantage of new, lower stock prices. On the other hand, you still want to keep the majority of your money invested for the long term, since there's no way of accurately timing the market, and you certainly don't want to miss out on any upside that might come before the market falls.

What not to do

If you think the stock market is looking a little too expensive and is due for a correction, there are a couple of moves you shouldn't make that are just as important as what you should do. Specifically:

Don't sell stocks just because you think the market is expensive. A correction will certainly occur someday, but it's entirely possible that the stock market will increase by another 20% or more before it does.

Don't invest with borrowed money. To be clear, this is a good rule of thumb no matter how expensive or cheap the stock market is, but as many people who got wiped out in the dot-com bust can tell you, it can be especially dangerous (and common) when stocks can seem to do nothing but rise. Think of it this way: If you buy $2,000 worth of a stock and its price drops 50%, you'll still have $1,000. On the other hand, if you buy $4,000 worth of that stock but borrow the other $2,000 and it drops 50%, you'll be completely wiped out.

The bottom line is that while nobody can predict when a stock market correction or crash will happen, there's nothing wrong with playing a little defense if you think the market has gotten a bit pricey. And if you follow the defensive playbook outlined here, you'll be setting yourself up well for no matter what happens next.