U.S. stocks edged up on Wednesday as comments by Federal Reserve officials suggested interest rates will stay low for some time, but gains were limited by strength in the U.S. dollar.

The dollar rose against a basket of currencies after hitting a 15-month low, weighing on energy shares.

Comments from top Fed officials on Tuesday that the U.S. recovery would be bumpy bolstered the view that interest rates will stay low and economic stimulus will remain intact, a boon for stocks.

Investors were waiting to see when all the stimulus would be withdrawn and what would happen then. Now, they think stimulus won't be withdrawn for a lot longer than they used to, said Michael Pento, senior market strategist at Delta Global Advisors.

The Dow Jones industrial average <.DJI> was up 22.60 points, or 0.22 percent, at 10,269.57. The Standard & Poor's 500 Index <.SPX> was up 3.56 points, or 0.33 percent, at 1,096.57. The Nasdaq Composite Index <.IXIC> was up 9.87 points, or 0.46 percent, at 2,160.95.

Stocks also received a boost from luxury homebuilder Toll Brothers Inc , which late Tuesday forecast revenue that was sharply higher than expected. The Dow Jones homebuilders index <.DJUSHB> rose more than 6 percent.

The Dow industrials and the S&P 500 index made new yearly highs, but volume was light due to the Veterans Day holiday. Federal offices and the U.S. bond market were closed.

The S&P energy sector <.GPSE> slipped 0.08 percent as the dollar gained back some ground. Dollar strength is typically a negative for companies with heavy overseas exposure.

The dollar has actually rebounded somewhat throughout the session, and that's probably the biggest factor contributing to the pullback, said Michael Sheldon, chief market strategist, RDM Financial, Westport, Connecticut.

Another drag on the market was Macy's Inc , the department store operator, which tumbled 8.1 percent to $17.85 after the company gave a gloomy outlook on same-store sales for the fourth quarter.

Helping stocks early in the day was data showing Chinese factory output rose to a 19-month high in October.

(Additional reporting by Ryan Vlastelica; Editing by Kenneth Barry)