NEW YORK — The U.S. economy is sending some worrying signals about a possible recession, yet the stock market has gone on a what-me-worry ride toward record heights.

What gives?

Put simply, while the stock market watches the economy, the two don't always move in lockstep. If investors see that companies are still bringing in profits, and stocks don't appear too expensive, they'll risk an investment even if the economy hasn't gotten an all-clear on the recession watch.

This week, the S&P 500 and Dow Jones Industrial Average climbed back to within 1 percent of their record highs set in July. A big reason is the recent easing of tensions in the U.S.-China trade war ahead of talks scheduled for next month, potentially diminishing the threat to the profits of U.S. companies. In addition, the Federal Reserve is expected to again cut interest rates. Lower rates make bonds less attractive investments and can, in turn, make investors more willing to sink their money into stocks.

Encouraging data on shopping trends and the job market also buoyed investors' mood.

Still, there is plenty to be concerned about. Investors know tensions in the trade war can easily escalate up again with another presidential tweet storm, as they painfully saw last month when stocks tumbled nearly 6 percent. Manufacturing is still weak worldwide. And the bond market has sent a signal that has been a fairly good predictor of recessions in the past.

Wall Street isn't ignoring those signals — there's a debate among analysts over whether a recession is coming to end the longest U.S. economic expansion on record.

But history shows that stocks can keep rising until a few months before a recession officially starts, as they did until October 2007, two months before the Great Recession swamped the economy and the stock market.

"The recessionary signals are still flashing yellow at this point," said Emily Roland, co-chief investment strategist at John Hancock Investment Management. She points to how three-month interest rates for Treasury bonds are higher than for 10-year Treasurys, a relatively rare reversal that has preceded past recessions.

Roland said advisers who manage money for clients tell her they're generally still optimistic about markets going higher. Their clients are typically much more negative.

S&P 500 funds have returned more than 20 percent this year, and the largest bond mutual fund has returned nearly 8 percent — yet many of those clients think they've lost money this year, Roland said.

The clients can be forgiven for the confusion, given the volatility over the last year. After diving nearly 20 percent in late 2018, the S&P 500 charged out to its best start to a year in decades, only to jerk down, up, down and back up again since May as worries about the trade war intensified.