A pedestrian walks past the NASDAQ building in New York City
A pedestrian walks past the NASDAQ building in New York City Reuters

(REUTERS) -- Stocks gave up early gains to turn flat on Tuesday, weighed down by mixed corporate earnings and weaker-than-expected data on Midwest business activity and consumer confidence.

Major indexes had opened higher on hopes a deal on a Greek debt swap was near and as European leaders showed signed of making progress in dealing with Europe's long-running sovereign debt crisis.

Business activity in the U.S. Midwest grew more slowly than expected in January due to a weaker labor market, according to the Institute for Supply Management-Chicago business barometer. Also, consumer confidence came in far below forecasts.

Shares of Exxon Mobil fell while Eli Lilly and UPS advanced as their quarterly reports reflected a mixed picture of corporate strength this earning season.

Earnings in general are not as robust as what we saw a year ago, said Nicholas Colas, chief market strategist at the ConvergEx Group in New York. Results are a little weak on the revenue line and that's putting a cloud on things.

The Dow Jones industrial average .DJI was up 0.76 points, or 0.01 percent, at 12,654.48. The Standard & Poor's 500 Index .SPX added 1.09 points, or 0.08 percent, at 1,314.10. The Nasdaq Composite Index .IXICrose 4.18 points, or 0.15 percent, at 2,816.12.

The S&P 500 triggered a bullish technical signal as its 50-day average ticked above its 200-day average. The occurrence, known as a golden cross, indicated a shift in mid-term momentum and usually means gains in the index six months down the road.

The S&P is up 4.4 percent in January, its best month since October, heading into the last trading day of the month. The Dow is up 3.6 percent and has had three straight months of gains. The Nasdaq is up almost 8 percent on strong results from technology companies.

Hopes have built that Greece was nearing a debt deal, lessening the odds of a messy default. In addition, European Union leaders agreed on a stricter budget discipline plan to prevent further debt build-up in the region.

We've been worried about Europe for two years now, and it seems that for the moment the market is giving EU leaders credit for beginning to build a lasting resolution, said Colas. There are still many miles to go before we sleep, but these are steps in the right direction.

Quarterly profits from drugmakers Pfizer Inc (PFE.N) and Eli Lilly & Co (LLY.N) both topped expectations. But Pfizer trimmed its 2012 view and Lilly repeated an outlook calling for a drop in 2012 earnings. Lilly was up 1 percent $39.64 and Pfizer dipped 0.2 percent to $21.53.

Exxon Mobil Corp's (XOM.N) fourth-quarter profit narrowly beat Wall Street's expectations, while United Parcel Service Inc (UPS.N) posted a better-than-expected quarterly profit, and U.S. Steel Corp (X.N) posted a wider-than-expected quarterly loss, but expects a better first quarter.

Exxon shares lost 1.4 percent to $84.31 before the bell while U.S. Steel gained 0.7 percent to $28.93 and UPS rose 0.9 percent to $75.50.

U.S. single-family home prices fell more than expected in November, according to the S&P/Case-Shiller composite index, highlighting a sector that continues to struggle to make a meaningful recovery. Futures moved little after the data.

Since December, Wall Street has largely decoupled from European equities, trading less in tandem with the region than in the months before. Investors still looked to developments from the region for any setbacks or signs of progress.