A trader uses his phone outside the New York Stock Exchange (NYSE) in New York.

The roaring stock market has professional investors riding high, so much so that it's rekindling memories of the 1987 crash.

In terms of sentiment, the difference between bulls and bears hasn't been this high in 30 years, according to the latest Investors Intelligence reading. Back then, stocks were bubbling their way toward the worst single-day sell-off in history when the Dow collapsed 22 percent on Oct. 19, 1987.

Bulls in this week's II survey totaled 63.5 percent against just 14.4 percent for bears. That's a spread of 49.1 points, well above the level the editors believe represents potential danger in the market.

A spread above 30 points signals "elevated risk" while 40 points calls for "defensive measures," according to II's formula.

"Sentiment readings have roughly followed their 1987 pattern," II Editor John Gray wrote. "Then the bulls peaked (near 65%) with initial market highs early that year and they returned to above 60% levels months later after more index records. In 1987 stocks crashed a few months after that. A repeat of that scenario suggests potential significant danger for over the remainder of 2017!"

The Investors Intelligence survey and others like it are generally considered contrarian indicators when sentiment gets to extreme levels. High levels of optimism indicate a selling opportunity and vice versa.

For instance, just before President Donald Trump's election, the bull-bear spread fell to 17.2 points, indicating a strong buy that preceded a more than 30 percent gain for the Dow industrials.

The rally this year has triggered a number of other warning signals about the market getting overheated.

Valuations as measured by what is known as the "Shiller CAPE," or the measure of price to earnings over a 10-year period, just touched the same level as it was when former Fed Chair Alan Greenspan issued his "irrational exuberance" warning about stocks in December 1996.

The cyclically adjusted price-earnings ratio is 31.42; it was last higher during the dot-com collapse that began in the late 1990s.

The more commonly cited P/E ratio of the compared with forward earnings also is elevated, currently at 17.9 compared with the 10-year average of 14.1

"This boat is now standing room only," wrote Peter Boockvar, chief market analyst at the Lindsey Group. "I still can't figure out why some think there is no euphoria in markets when one has to go back 30 years to see this wide a spread between bulls and bears."

WATCH: Here's an area outside of U.S. stocks that could signal trouble.