U.S. stocks edged higher on Monday as optimism over stronger-than-expected Citigroup earnings and retail sales data outweighed a fall in energy shares to lower oil prices.

Investors remained cautious about Europe, waiting for signs Spain was ready to formally request a bailout, which is seen as necessary to deal with its debt crisis.

Both the Dow and S&P 500 are coming off their worst weekly performance in four months, putting both indexes right on their 50-day moving averages, a technical support level which could trigger further declines if broken.

After challenging five-year highs in mid-September, the benchmark S&P 500 has fallen 2.2 percent on concerns about the strength of corporate earnings.

Many investors believe when Spain asks for a bailout, that will take the pressure off the market, but there is skepticism about the conventional wisdom, said Paul Mendelsohn, chief investment strategist at Windham Financial Services in Charlotte, Vermont.

"It's very often wrong in terms of how the market actually responds. As long as we hold where we are and don't see a significant breakdown, the bulls haven't lost the battle yet," he said.

Citigroup Inc rose 3.9 percent to $36.11 after posting adjusted earnings that surged from the prior year and beat expectations. The growth came as mortgage lending increased and capital markets results rebounded. The PHLX oil service sector lost 0.6 percent.

But energy shares fell as U.S. crude fell nearly 1.8 percent to $90.20 after dipping below the $90 mark as worries over global demand persisted.

September retail sales rose 1.1 percent, above the 0.8 percent growth that had been anticipated, but a survey of manufacturing activity in New York state shrank in October.

The Dow Jones industrial average gained 39.53 points, or 0.30 percent, to 13,368.38. The Standard & Poor's 500 Index rose 4.01 points, or 0.28 percent, to 1,432.60. The Nasdaq Composite Index added 6.47 points, or 0.21 percent, to 3,050.59.

Sprint-Nextel Corp edged up 0.4 percent to $5.75 after Japanese mobile operator Softbank Corp <9984.T> said it would buy up to 70 percent of the company for $20.1 billion.

Sprint competitors AT&T Inc lost 1.4 percent to $35.13 as the biggest drag on the Dow while Verizon Communications Inc shed 0.5 percent to $44.40. The telecom sector lost 0.6 percent as the worst performing S&P sector.

Profits of S&P 500 companies are seen dropping 2.4 percent this quarter from a year ago, according to Thomson Reuters data.

With only 7 percent of S&P companies having reported, 60 percent of companies have topped profit expectations - less than the average beat rate of 67 percent for the past four quarters.

Drugmaker shares advanced, led by Eli Lilly and Co , up 4.3 percent to $52.63 and Abbott Laboratories , up 3.7 percent to $71.86. The PHLX drug index climbed 1.7 percent.

Eli Lilly rose after the drugmaker said a late-stage study of its experimental gastric cancer drug met its main goal of improving overall survival while Abbott rose after results from a midstage study of hepatitis C medicines.

(Reporting by Chuck Mikolajczak; Editing by Kenneth Barry)