Stocks edged higher Wednesday at the end of a choppy trading session as investors snatched up beaten-down shares ahead of the Fourth of July holiday, snapping a losing streak that had pushed indexes to multiyear lows.

The Dow Jones industrial average rose 47.22 points, or 0.52 percent, to 9,054.97, after falling for three straight sessions. The technology-laced Nasdaq Composite Index was up 22.35 points, or 1.65 percent, at 1,380.17, after sinking to 5-year lows over the past two sessions.

The benchmark Standard & Poor's 500 Index broke a three-session losing streak to rise 5.90 points, or 0.62 percent, to 953.99, according to the latest available figures. The index fell to a 4 1/2-year low on Tuesday. During the day, the index slipped below 944.75, the intraday low hit on Sept. 21 after the Sept. 11 attacks and a key level of technical support.

"Sellers have done all they have to do and there's no impetus to push the market lower," said Robert Cohen, head trader at Credit Suisse First Boston.

Still, dour forecasts from firms like Advanced Micro Devices weighed on sentiment, and investors, bracing for the next big accounting blowup, fled shares of complex companies such as General Electric Co.

"We're going a little higher but don't read too much into it," said Anthony Iuliano, head equity trader for Glenmede Trust Co. "There are definite worries because we're in the preannouncement season. We need to have a few more days of gains for it to mean anything."

The U.S. stock market is scheduled to close early on Friday.

Chipmaker AMD (AMD) weighed on early sentiment after cutting its quarterly sales forecast for the second time in two weeks as it fell victim to the continuing weakness in the personal computer market and competition from its archrival Intel Corp. (INTC). AMD fell 37 cents, or 4.2 percent, to $8.43, while Intel advanced $1.18, or 7.1 percent, to $17.75.

Investors were also skeptical of companies with complex operations and balance sheets. GE, maker of jet engines, light bulbs and plastics, sank as investors were spooked by scandals at other companies. GE (GE), at one point, fell to lows unseen since October 1998, but closed down only 20 cents, to $27.90.

"There are some who don't want to stick around to watch the next shoe drop," said Charles Reinhard, senior U.S. investment strategist at Lehman Brothers. "The fear is this market has more shoes than Imelda Marcos."

But stocks turned around in late afternoon as some investors took advantage of recent sharp declines to add a few positions.

A short-selling rally also added to gains. Short sellers are traders who sell borrowed stocks in a bet the market will fall and they can replace those borrowed shares at a lower price.

"We're seeing some short covering here because these guys have made a lot of money and they're taking some profits and going home," said Iuliano.

On Tuesday, the S&P 500 fell to its lowest level since January 1998, plunging through lows hit in the wake of the Sept. 11 attacks on the United States and past the October 1998 lows hit during the near collapse of hedge fund Long-Term Capital Management.

But on Wednesday, some of the most-battered stocks showed improvement. AOL Time Warner Inc. (AOL) jumped $1.54, or 12 percent, to $14.06 and was the most-active NYSE stock after Merrill Lynch analyst Jessica Reif Cohen said concerns about accounting irregularities at the media giant have been overblown and current weakness in the company's shares is a buying opportunity.

WorldCom Group Inc. (WCOM) shares more than doubled in value, rising 12 cents to 22 cents after its new boss apologized for the accounting scandal gripping the company. More than 1 billion shares of the stock were traded.

Worries about a potential attack on U.S. soil over the Fourth of July holiday kept many investors on edge, analysts said, but the market may be poised for a snapback after weeks of decline, traders said. The positive close added to those hopes.

"I think a lot of the negativity has been priced in at these lows," said John Person, head financial analyst with Alaron Trading Corp. "We could see a rally next week."

A mixed bag of economic data also helped whipsaw the market after monthly factory orders came in better than expected, but a key gauge of the services sector disappointed investors.

Orders for U.S. manufactured items beat expectations in May, boosted by demand for machinery and computer products in a fresh indication the sector hardest hit by the recession is recovering. Factory orders climbed 0.7 percent, the Commerce Department said.

The Institute for Supply Management (formerly NAPM), however, said its June non-manufacturing index read 57.2, down from 60.1 in May. Economists in a Reuters survey had forecast, on average, a June reading of 58.8.

Trading volumes were strong in early trading, but tapered off in the afternoon as the bond market closed early and many traders slipped out ahead of Thursday's Independence Day holiday. About 1.53 billion shares traded hands on the Big Board, while about 2.66 billion traded on Nasdaq.

Despite index gains, breadth was negative and 19 stocks fell for every 12 that gained on the New York Stock Exchange. About 19 stocks fell for every 15 that rose on the Nasdaq.

The Russell 2000 index, which tracks smaller company stocks, fell 3.37, or 0.8 percent, to 429.47.

Overseas, Japan's Nikkei stock average finished Wednesday up 1.8 percent. But in Europe stocks were sharply lower. France's CAC-40 sank 3.0 percent, Britain's FTSE 100 slid 3.4 percent, and Germany's DAX index fell 1.4 percent.

Reuters and the Associated Press contributed to this report.