Investors have not been this bullish about stocks since 1987, according to a recent survey. A statue of a bull is seen outside the entrance to the Frankfurt Stock Exchange in Germany on Feb. 27. (Alex Kraus/Bloomberg)

The stock market keeps going up and up and up — and investors are feeling pretty good about it.

But financial pros have two words of advice for people looking to jump into the market as it flirts with new records: Move slowly.

Buoyed by President Trump’s promises of tax cuts, regulatory reform and increased infrastructure spending, the Dow Jones industrial average sailed past 21,000 last week, barely a month after it closed above 20,000 for the first time. Those gains, combined with stronger economic reports, have some investors feeling like the rally is just getting started.

Investors have not been this bullish about the stock market in 30 years, according to a recent survey of market professionals done by Investors Intelligence, an investment research firm.

But this kind of euphoria can also make some investors nervous about what will come next. Are the recent highs a sign that the market is nearing a peak and ready for a tumble? (The last time investors were this optimistic was 1987, the year of the infamous “Black Monday” market crash.) Or is this simply the market breaking new ground as part of a long-term rally?

The jury is still out.

But in the meantime, investors looking to buy more stocks can take the guesswork out of the equation by spreading out their purchases over time, financial advisers say. “The biggest mistake I see investors make is they have an all-or-none mind-set,” says JJ Kinahan, chief market strategist for TD Ameritrade.

Take someone with $25,000 to invest. Instead of pouring all of the money into the market at once, you can start by investing $5,000, says Kinahan. The rest of the money can be invested in steady increments over time.

This way, you can still benefit from market gains if stocks continue to rise. But by not putting all of your money at risk, you would still be somewhat protected if stocks fall, Kinahan says.

One approach is to start out by buying stocks in equal increments over a period of time, say six months or so, says Jeff Porter, chief investment officer of Sullivan, Bruyette, Speros and Blayney, a wealth management firm based in McLean, Va. If the market slides by 5 percent or more during that time, investors can take advantage by snapping up more stocks at discount, Porter says.

The tried-and-true method, known as dollar cost averaging, can help remove some of the emotions that cause investors to make horrible mistakes with their money, says Antwone Harris, a vice president and senior financial consultant with Charles Schwab.

Too often, people trying to time the ebbs and flows of the market end up buying stocks when they’re expensive and selling stocks when they’re down — a bad pattern that can exacerbate their losses.

Instead of trying to predict where stocks will go next, investors trying to decide how to allocate their money should focus on when they’ll need the cash, Harris says. Money that will be needed in five years or less — such as emergency savings or the down payment for a home — should probably be kept out of the stock market, he says.

And once investors have a long-term plan for their money, they should stick with it, Harris says. Consider people who were buying stocks in 2007, right before the Dow fell from about 14,000 to below 7,000. Those investors may have felt like they had the “worst luck” after seeing their portfolios cut in half, Harris says.

But if they were patient and stayed invested as the Dow climbed up to 21,000, they would have definitely made up those losses — and then some, he says.

Read more:

Warren Buffett says this simple mistake has cost investors more than $100 billion

Trump calls for review of long-awaited rule meant to protect retirement savers

How to start investing if you have $1,000 or less