Investors are betting the economy is slowing and a recession is on the way, CNBC's Jim Cramer said Wednesday.

That explains the defensive stock rallies in PepsiCo (1.80%), Kimberly-Clark (1.57%) and Hershey (2.16%) during the session, he said, along with the roughly 5% surge in cloud stocks Salesforce and Okta.

The stocks outperformed the major indexes, which all posted gains under 1%.

"[Defensive stocks] can do just fine during a slowdown," the "Mad Money" host said.

"Meanwhile, the secular growth stocks keep climbing, climbing, climbing for the same reason — they don't need a strong economy either," Cramer said. "If we're in a deflationary environment, their future earnings growth looks a lot more attractive, provided they can keep making the numbers, and I think they can."

Wall Street's focus shifted after Federal Reserve Chair Jerome Powell announced Tuesday that the agency would monitor the economy for signs of weakness, Cramer said. The central bank in December tightened its monetary policy too much, and bulls are now hoping for economic activity to warrant an interest rate cut, he said.

With the economy on the other side of a rate cycle, the market was able to advance for a second straight day, he said. Investors got a sign that the economy is slowing after payroll processing firm ADP revealed that businesses added 27,000 jobs in May. Cramer said the low reading suggests the non-farm payroll report Friday could be weak.

"Thanks to the magic of the Federal Reserve, we've entered a market, right now, where bad news for the economy is actually good news for stocks," he said.

The bulls are looking to three events to put pressure on the Fed to reduce interest rates and spur more activity: falling oil prices, tariffs and the bond market.

Oil prices slumped 3.4% to levels not seen since January. Markets are still waiting to see a breakthrough in trade relations with China and Mexico. The yield on 10-year U.S. Treasury bonds dropped to 2.12%, lower than the benchmark interest rate of between 2.25% and 2.5%.

Cramer said that yield curve inversion is "a sign that the Fed was way too aggressive with its rate hikes last year."

However, the host doesn't think Powell will reverse course on its December rate hike intended to stave off inflation.

"Look, I hope I'm mistaken. I would love a rate cut next month, but hope should not be part of the equation," he said.

"Given that [President Donald Trump] has endlessly pressured Jay Powell to cut, he needs some cover before he can take action — otherwise he'll look like a puppet. And the only thing that gives the Fed cover is a slower economy. Good thing, because that's what we're getting."