New York (CNN Business) The Dow is brushing up against all-time highs , suggesting the coast is clear for the American economy. Yellow lights, however, are still flashing in the bond market about the risk of a recession.

Although Treasury rates have climbed rapidly off their recent lows, parts of the yield curve remain inverted. In the past, long-term bonds trading below short-term bond yields has been a reliable predictor of looming economic trouble.

Maybe we, as a market, got too bearish."

The stock and bond markets are painting two different pictures about the economy -- and they both can't be right.

The mixed messages reflect the deep uncertainty about the fate of the longest economic expansion in modern history. The on-again, off-again nature of the trade war between the United States and China is making it very difficult to determine what comes next.

History shows that the bond market often sniffs out economic trouble first.

For instance, the yield curve inverted in 2006, sending out a loud alarm about the risk of a recession. The S&P 500 didn't top out until mid-October 2007. Mere weeks later, the United States entered what would become the worst downturn since the Great Recession.

"Sometimes the stock market is late to the party on the recession front," said Jeffrey Sherman, deputy chief investment officer at DoubleLine Capital.

Dow flirts with record high

Today, parts of the yield curve are inverted and Treasury rates are down sharply from a year ago.

By contrast, the Dow finished higher on Friday for the eighth day in a row, the longest winning streak since May 2018. The S&P 500 is just 1% away from all-time highs.

"The yield curve is telling you we're going into recession," said Sherman, co-portfolio of the DoubleLine Core Fixed Income Fund. "But maybe the stock market has been right all along. We won't know for sure for another year or two."

There is no playbook for understanding the fallout of a full-blown trade war between the world's two largest economies. That uncertainty is amplified by the fact that the tariff battle is exacerbating a global slowdown.

"They've been fooling us for 18 months on the tariffs," said Sherman. "Maybe we, as a market, got too bearish."

Bond yields have also bounced sharply off their historic lows. The 10-year Treasury rate surged by the most since June 2013, according to Reuters. After sinking to 1.43% on September 3, the yield has climbed to nearly 1.9%.

More importantly, the two and 10-year Treasury yields are no longer inverted.

"Investors had gotten too pessimistic. Growth is likely to recover," said Brian Levitt, Invesco's global market strategist for North America.

NY Fed: 38% chance of a recession

However, another closely-watched yield curve, the gap between the three-month and 10-year Treasury, is still upside down after first inverting in the spring.

That's the yield curve that the New York Federal Reserve monitors to forecast recessions. The NY Fed estimates there is a 38% chance of a recession in the United States over the next 12 months, the highest risk since the last downturn.

Still, that doesn't mean a recession is necessarily imminent.

On average, it has taken 15 months between this yield curve inversion and a recession to strike, according to SunTrust.

"Even if the yield curve is right and we are going to recession, you still have a long lead time before it hits," said Keith Lerner, market strategist at SunTrust.

But Lerner noted that warning signal hasn't been backed up by stress in the credit markets. He pointed to the strong performance of the lowest rated investment grade bonds.

"Credit is the bloodline for the economy. But we're not seeing stress in the credit markets," said Lerner.

The trade war is the key

Much will depend on how the trade war plays out.

If the Trump administration goes forward with the next round of tariffs, it would deal another blow to the already-hurting manufacturing sector. That in turn could spill over into the rest of the economy, risking a downturn.

But if the Washington and Beijing are able to reach an agreement that delays those tariffs or even rolls back existing ones, that could spark a rebound in the economy.

"If we're going into recession, this is the most well-telegraphed recession ever," said DoubleLine's Sherman. "Everyone is talking about a recession coming. Usually, when consensus gets so extreme, things don't happen. The opposite does."