The S&P 500 index hit a fresh 7-month high before giving up some gains on Wednesday after mixed data on the U.S. economy and news of a possible delay in Greece's bailout.

The S&P hit a peak of 1,354.72 shortly after the open but quickly retreated. With the index posting gains every week this year except for a 0.2 percent decline last week, many market participants were convinced stocks are overbought.

The percentage of S&P 1500 stocks trading above their 200-day moving average has risen from 8 percent to 79 percent during the market's advance from its October 2011 low, said Ari Wald, equity strategy researcher at BBH.

Given the market's internal strength, an orderly pullback in the coming months is likely to create a tactical buying opportunity.

The Dow Jones industrial average <.DJI> was down 39.51 points, or 0.31 percent, at 12,838.77. The Standard & Poor's 500 Index <.SPX> was up 1.42 points, or 0.11 percent, at 1,351.92. The Nasdaq Composite Index <.IXIC> was up 15.86 points, or 0.54 percent, at 2,947.69.

Early gains were dented after European Union sources said finance officials were examining ways of delaying parts or even all of a second bailout for Greece, while still avoiding a disorderly default. That rekindled fears about the region's debt crisis.

Stocks were boosted earlier after a gauge of factory activity in New York state rose to its highest level in more than 1-1/2 years in February and after China's chief central banker reiterated the country will keep investing in euro zone debt.

A separate report showed U.S. industrial production was unexpectedly flat in January, but a second straight month of gains in manufacturing pointed to underlying strength in the economy.

Decliners on the Dow, which underperformed the broader market, included industrial and material stocks like Caterpillar Inc and Alcoa Inc .

I don't think anybody is looking at these numbers (like industrial production) as robust, but there is a continual tone that things are getting better, said Mark Lehmann, director of equities at JMP Securities in San Francisco.

Financial stocks were among the top gainers, with the S&P financial sector <.GSPF> up 0.7 percent, following European banks that were boosted after BNP Paribas' posted forecast-beating results.

Housing stocks got a lift after data showed U.S. homebuilder sentiment rose in February to the highest level in more than four years. The PHLX housing index <.HGX> rose 0.4 percent.

(Reporting By Angela Moon; editing by Jeffrey Benkoe)