(AP) -- Stocks recovered from a late-afternoon bout of selling on Wall Street to finish modestly higher Wednesday, giving the benchmark S&P 500 its fifth straight gain.
Technology stocks powered much of the rally, led by chipmakers. Retailers, homebuilders and hotel operators were among the big gainers. Energy companies, consumer goods makers and industrial stocks took the heaviest losses.
The market's last-minute rebound after an early rally faded echoed the prior day's results and came in a mostly quiet week for market-moving news. That could change as swiftly as Friday, when the government issues its closely watched monthly tally of hiring by U.S. employers.
Investors were also gearing up for a new round of corporate earnings reports set to begin coming out next week. The overall forecast is for a weak round of results, with earnings by S&P 500 companies expected to contract by 4 percent, according to FactSet.
Even so, traders are expecting company earnings to come in a little bit above current forecasts and for results to be stronger later this year, said Sam Stovall, chief investment strategist at CFRA.
"The remaining quarters of the year are currently forecast to be higher," Stovall said. "So, in many ways, analysts think that the first quarter was an anomaly not likely to be repeated."
The S&P 500 index added 6.16 points, or 0.2%, to 2,873.40. The index is now about 2 percent shy of its most recent all-time high reached on September 20.
The Dow Jones Industrial Average rose 39 points, or 0.1%, to 26,218.13. The Nasdaq composite, which is heavily weighted with technology stocks, climbed 46.86 points, or 0.6%, to 7,895.55. The Russell 2000 index of smaller company stocks picked up 7.59 points, or 0.5%, to 1,560.91.
Major indexes in Europe finished higher.
Despite more volatile trading this week, the major U.S. stock indexes are on track to end the week with gains, adding to the market's blockbuster returns in the January-March period. The S&P 500 is now up 14.6% this year.
Whether the market builds on that momentum depends much on the upcoming wave of company earnings reports, which should provide investors with an updated outlook on growth in corporate profits and a better read on the state of the global economy.
"With recent economic data out of China showing a possible bottoming, combined with sporadic strength of indicators here in the U.S., investors are of the mindset that the soft patch has already been negotiated," Stovall said.
Delta will kick off the earnings results for airlines early next week, with JPMorgan and Wells Fargo leading bank earnings later in the week.
Traders also have had their eye out for developments in the trade negotiations between the U.S. and China, which resumed Wednesday. Investors hope that the world's two largest economies can agree to pull back on some of those tariffs and move toward a more stable trading partnership.
Markets have swayed for months as the contentious talks drag on. The latest reports say that both sides have resolved most of the key issues, with some pledges from China to end practices viewed by the U.S. as technology theft.
First up, however, is the government's monthly U.S. jobs report, due out Friday. Economists project a gain of 170,000, according to FactSet.
Investors shrugged off a report from payroll processor ADP on Wednesday showing private U.S. businesses added 129,000 jobs last month, down from the previous month's gain of 197,000.
Chipmakers led the gainers in the technology sector. Advanced Micro Devices jumped 8.5% and Micron Technology climbed 3.4%.
Energy companies, consumer goods makers and health care stocks lagged. Noble Energy slid 2%, tobacco company Altria Group dropped 4.8% and Mylan fell 2.3%.
Video game retailer GameStop slid 4.7% after reporting weak first-quarter sales, with more of the same likely for the year. It expects sales to fall as much as 10% this year and would not give investors a profit forecast. The stock has lost about two-thirds of its value since 2015 as revenue declines while gamers bypass retail shops for games that can be bought and played online.
Dave & Buster's added 4.9% after the restaurant and arcade operator beat fourth-quarter forecasts. A key sales figure jumped and also beat forecasts as the company attracted more business with the addition of a virtual reality game platform.
Blue Apron, which delivers ready-to-make meal kits, jumped 7.3% as it changes leadership. CEO Bradley Dickerson resigned and is being replaced by former Etsy executive Linda Kozlowski. The company has been struggling since it went public in June 2017. Its stock is down about 90 percent since then.
Bond prices fell. The yield on the benchmark 10-year Treasury rose to 2.52% from 2.48% late Tuesday.
The dollar rose to 111.47 yen from 111.37 yen on Tuesday. The euro strengthened to $1.1240 from $1.1198.
Energy futures closed mostly lower. Benchmark U.S. crude dropped 0.2% to settle at $62.46 a barrel. Brent crude, used to price international oils, closed 0.1% lower at $69.31 a barrel.
Wholesale gasoline climbed 1.2% to $1.95 a gallon, heating oil gave up 0.1% to $2.01 a gallon and natural gas fell 0.3% to $2.68 per 1,000 cubic feet.
Gold was little changed at $1,295.30 an ounce, silver rose 0.3% to $15.10 an ounce and copper gained 1.5% to $2.95 a pound.