U.S. stocks traded edged higher on Tuesday as investors awaited the outcome of discussions on a bailout package for Greece that would help the country avoid a chaotic default.

Greek officials worked on the draft of a text on the 130-billion-euro bailout plan that will be put to political leaders for approval as strikers protesting against more austerity tussled with police outside parliament.

A light U.S. economic calendar this week shifted investor focus back to the euro zone. With the S&P 500 up 6.6 percent this year the market has grown cautious before Greek leaders put pen to paper on the terms of the deal.

Michael Sheldon, chief market strategist at RDM Financial in Westport, Connecticut, said the market was holding up well despite some profit taking as investors bet a deal would be completed.

If investors thought the Greek talks were going to collapse, financial markets will be a lot weaker than they are, he said. But a lasting solution continues to be something that is hard to come by.

Cyclical areas of the market that led the recent rally were the weakest on Tuesday. The S&P energy <.GSPE> and industrial <.GSPI> indexes fell 0.8 percent. Boeing Co was the biggest drag on the Dow industrials, dropping 1.3 percent to $74.46.

A disorderly Greek debt default would almost certainly lead to increased fiscal problems for weaker members of the euro zone and risks wreaking havoc in credit markets. The impact could also dampen the U.S. recovery.

The Dow Jones industrial average <.DJI> was up 28.42 points, or 0.22 percent, at 12,873.55. The Standard & Poor's 500 Index <.SPX> was up 1.29 points, or 0.10 percent, at 1,345.62. The Nasdaq Composite Index <.IXIC> was up 4.99 points, or 0.17 percent, at 2,906.98.

On the equities side, we've come a long way, and we are getting into overbought territory, so most of us are expecting a bit of a pullback or a period of consolidation, said Frank Lesh, a futures analyst and broker at FuturePath Trading LLC in Chicago. The depth of the pullback really depends on Greece and the European debt problems.

The benchmark S&P 500 index had risen for five straight weeks on the back of improving U.S. economic data, capped by the Friday payrolls report. Accommodative monetary policy around the world has also helped to fuel the rally.

Coca-Cola Co rose 1.5 percent to $69.05 after the soft-drink maker reported better-than-expected quarterly results and announced a new cost-savings program.

As earnings season winds down, investors awaited results from companies including Lincoln National Corp and Walt Disney Co .

According to Thomson Reuters data through Tuesday morning, of the 301 companies in the S&P 500 posting results, 60 percent topped expectations, tracking below recent quarters at this point of the reporting season.

Emerson Electric Co dipped 2.9 percent to $51.76 after it reported lower quarterly sales and earnings as last year's floods in Thailand disrupted supply chains and weak European economies hurt demand.

In a troubling sign for the banking sector, UBS predicted more weakness in investment banking after a restructuring of the business failed to prevent an earnings hit from the euro-zone debt crisis and worries about the global economy. Shares dipped 1.7 percent to $14.12 in New York trade.

ArcelorMittal forecast improvement in the first half of 2012 after a weak end to last year, with a clear pick-up in North America but continued concerns about Europe. U.S.-listed shares of the world's largest steelmaker rose 1.6 percent to $21.83.

European shares fell on the Greece talks and after disappointing results from investment bank UBS AG and engineering firm Alfa Laval AB . The FTSEurofirst 300 <.FTEU3> index of top European shares fell 0.3 percent. <.EU>

Federal Reserve Chairman Ben Bernanke on Tuesday renewed a pledge to prevent Europe's financial crisis from damaging the U.S. economy in testimony before Congress that mirrored remarks he made last week.

(Editing by Padraic Cassidy)

(This story corrects seventh and seventeenth paragraph to show Alfa Laval is an engineering firm and not a shipbuilder)