Stocks were largely flat on Wednesday as investors balanced comments from the Federal Reserve on the economy and banking sector against the recent, five-day rally.

The Fed said most of the largest U.S. banks passed their annual stress test in a report that underscored the recovery of the financial sector but called out a few laggards, including Citigroup Inc.

The Fed also said late Tuesday it expects moderate growth over coming quarters with the unemployment rate declining gradually versus the modest growth the central bank said it expected in January.

Banks have been a major component of the 11 percent rally in the S&P for the year, with the KBW Bank index <.BKX> up nearly 21 percent and the S&P financial sector index <.GSPF> up nearly 18 percent.

Certainly this is good news for the overall domestic financial system. It really shows banks have turned themselves around, raised capital significantly and are being much smarter and less aggressive about their capital positions, and that should give investors confidence in the system, said Tim Ghriskey, chief investment officer of Solaris Asset Management in Bedford Hills, New York.

There is constant chatter about a correction ... given we've been pretty much since December on an uninterrupted rise, Ghriskey said.

Bank of America Corp climbed 1.6 percent to $8.63 in early trading. Citigroup Inc dropped 3.6 percent to $35.13 as the biggest drag on the S&P 500.

The Dow Jones industrial average <.DJI> gained 11.69 points, or 0.09 percent, to 13,189.37. The Standard & Poor's 500 Index <.SPX> shed 0.30 points, or 0.02 percent, to 1,395.65. The Nasdaq Composite Index <.IXIC> added 2.32 points, or 0.08 percent, to 3,042.20.

The increasing optimism on the U.S. economy helped boost the dollar, which hit an 11-month high against the yen and 1-month high versus the euro.

Data on Wednesday showed import prices rose in February on sharply higher petroleum costs, but there were few signs of underlying imported inflation pressures, and imported capital goods prices edged down 0.1 percent after advancing 0.4 percent in January.

Semiconductors moved higher, led by a 6.6 percent jump in NXP Semiconductors NV to $26.51 after Goldman Sachs added the chip maker to its conviction buy list and boosted its price target to $30. The PHLX semiconductor index <.SOX> climbed 1.2 percent.

Gaming company Zynga Inc edged up 0.2 percent to $13.40 premarket after the online gaming company announced a $400 million secondary offering.

(Editing by Padraic Cassidy)