Updated from 4:10 p.m. EDT

Stocks staged a stunning turnaround in the final hour of trade Wednesday, shrugging off soaring oil prices and a disappointing report on orders for durable goods that had earlier dragged the markets back near their lowest evels of the year.

The Dow Jones industrial Average swung to a gain of 31.93 points, or 0.32%, to 10,117.07; the S&P 500 finished with a fractional gain at 1095.42; and the Nasdaq Composite finished down 10.83 points, or 0.58%, to 1858.26. The 10-year note was trading up 7/32 to yield 4.59%, while the dollar was higher against the yen and roughly even with the euro.

Volume stayed moderate, with more than 1.5 billion shares trading on the New York Stock Exchange, where advancers and decliners were about even. On the Nasdaq, more than 1.8 billion shares changed hands, and decliners outnumbered advancers by about 3 to 2.

The late-session bounce off Monday's lows in the Nasdaq and S&P 500 lent credence to a weekly research note published earlier by Merrill Lynch that hinted of a technical bottom forming in the market.

"Now that the market's narrow, dull trading range pattern of recent months has been widely recognized and discussed, it is likely approaching an ending," wrote Richard McCabe, chief market analyst with Merrill. "Momentum indicators are not fully oversold yet, so some additional downside testing may be required in the next week or two to further improve these indicators prior to the start of a durable new phase of advance."

Mark Arbeter, chief technical analyst with Standard & Poor's, took a more cynical view in a note published Wednesday. "The recent market action is reminiscent of a bear market," he wrote. "Positive fundamental news has been met by selling. The slide in the indices is interrupted occasionally by short-covering rallies that do not generate any follow-through. The abundance of oversold readings over the last couple of months have led to only short-term recoveries, and many stocks that were holding up technically have broken down, providing few places to hide."