NEW YORK (AP) -- A day of back-and-forth trading Thursday ended with the fifth gain in a row for U.S. stocks. Industrial companies like Boeing and General Electric rose while retailers fell as Macy's suffered its biggest loss of all time.
Stocks struggled in the early going and the Dow Jones Industrial Average lost 175 points after U.S. and Chinese officials wrapped trade talks in Beijing. Transportation and machinery companies climbed after the U.S. Trade Representative said China agreed to buy more agricultural and manufactured products.
Macy's said its sales over the holidays were worse than expected and slashed its annual profit and sales forecasts. Kohl's and L Brands also posted disappointing results and a wide variety of retailers plunged as investors worried that the stock market's December plunge stopped some shoppers from spending as much as they had planned.
"High-end consumers, even though they're making decent money (and) the economy is going on relatively strong, it may have affected their willingness to splurge over the holidays," said Ken Perkins, president of the research firm Retail Metrics. "It was not good timing at all."
The S&P 500 index added 11.68 points, or 0.5 percent, to 2,596.64. The Dow Jones Industrial Average gained 122.80 points, or 0.5 percent, to 24,001.92 after it fell 175 points in the morning.
The Nasdaq composite rose 28.99 points, or 0.4 percent, to 6,986.07. The Russell 2000 index of smaller-company stocks picked up 6.63 points, or 0.5 percent, to 1,445.43.
U.S. negotiators said China's delegation pledged to buy more energy and agricultural products and manufactured goods. That helped Boeing climb 2.6 percent to $352.61 and General Electric jumped 5.2 percent to $8.94 while Deere rose 3.1 percent to $159.12.
However, that point is considered a relatively minor area of disagreement, and there were no hints of progress on bigger issues. The U.S. wants China to change its technology policy to reduce cyber theft of trade secrets and seeks more access to the Chinese market and increased protection for foreign patents and copyrights.
Macy's said holiday sales slowed in the middle of December and the department store cut its annual profit and sales forecasts. Its stock plunged 17.7 percent to $26.11 in heavy trading. Macy's went public in February 1992 and reached an all-time high of almost $73 a share in mid-2015, but four of the five biggest one-day plunges in its history have come in the last three years.
Macy's announcement came as a surprise because investor expectations for the holiday season have been high. Unemployment is the lowest it's been in decades, wages are rising and consumer confidence is high, while gas prices dropped late last year. In late December, stocks rallied after Mastercard SpendingPulse said shoppers spent $850 billion between Nov. 1 and Dec. 24, an increase of 5 percent from the same time a year earlier.
But the stock market fell sharply in October and then took a dramatic drop over the first three weeks of December. Shortly afterward the federal government went into a partial shutdown that is still ongoing.
While large numbers retailers took steep losses Thursday, Perkins said the market turmoil is a much bigger problem for companies like Macy's because most stocks are owned by relatively wealthy people. That means big box stores and companies that sell less expensive goods won't be affected as much, as shown by Target's stronger sales report. Perkins added that said Amazon likely had a "stellar" holiday season.
Chipmakers rose and other technology stocks edged higher, while high-dividend stocks like utilities and household goods companies made strong gains.
Oil prices extended their rally to a ninth consecutive day. U.S. crude added 0.4 percent to $52.59 a barrel in New York. It's now up 23.7 percent since hitting an 18-month low on Dec. 24. Brent crude, the international standard, slid 0.4 percent to $61.68 a barrel in London.
Federal Reserve Chairman Jerome Powell was interviewed at the Economic Club of Washington DC. Stocks briefly fell after Powell said he expects the Fed's $4 trillion bond portfolio to shrink until it is "substantially smaller than it is now." Powell noted that the Fed had about $1 trillion on its balance sheet before the 2007-08 financial crisis.
The Fed's bond holdings are slowly shrinking, which tends to put upward pressure on long-term interest rates. Investors have grown concerned about the effects of those tighter credit conditions as the global economy slows. Powell said in December that the Fed could slow the changes to its portfolio if necessary.
Bond prices slipped. The yield on the 10-year Treasury note rose to 2.74 percent from 2.72 percent.
In other energy trading, wholesale gasoline added 0.4 percent to $1.43 a gallon and heating oil rose 1.3 percent to $1.91 a gallon. Natural gas dipped 0.5 percent to $2.70 per 1,000 cubic feet.
Gold fell 0.4 percent to $1,287.40 an ounce and silver shed 0.6 percent to $15.64 an ounce. Copper lost 0.7 percent to $2.97 a pound.
The dollar rose to 108.42 yen from 108.28 yen and the euro fell to $1.1500 from $1.1544.
France's CAC 40 lost 0.2 percent while Germany's DAX edged up 0.3 percent. The British FTSE 100 rose 0.5 percent.
Japan's Nikkei 225 index, which gained more than 1 percent on Wednesday, fell 1.3 percent and the Kospi in South Korea dropped 0.1 percent. Hong Kong's Hang Seng recovered from early losses and added 0.2 percent.