Stocks rose on Wednesday after a selloff in the previous session, with technology shares gaining, as homebuilder stocks rallied after a positive earnings report from Toll Brothers Inc.

Investors had been cautious earlier ahead of the conclusion of a Federal Reserve meeting that could shed light on the state of the economy.

The Fed's monetary policy committee, which wraps up its two-day meeting Wednesday, is expected to leave the key target interest rate unchanged. But investors will parse the Fed's policy comments for any changes in its outlook or its program to buy Treasury bonds.

Applied Materials Inc added to gains for the tech-heavy Nasdaq index, rising 4.54 percent to $13.81 after Morgan Stanley raised its price target. Applied Materials, the world's largest producer of chip-making gear, reported its quarterly results after the bell on Tuesday and said it would at least break even this year thanks to new orders and deep cost cuts.

Toll Brothers Inc shares advanced by 10.6 percent to $22.65, after the luxury-home builder said its net signed contracts rose in the third quarter. But the firm said that it was expecting to report a 42 percent drop in homebuilding revenue next quarter, a further sign of a housing market still suffering from recession.

An index of homebuilder shares gained 4.4 percent. <.DJUSHB>

We had a couple of earnings reports and economic data that were positive for buyers to come back into market, but there is really no reason for investors to be jumping in ahead of the Fed commentary this afternoon, said Kurt Brunner, portfolio manager at Swarthmore Group in Philadelphia, Pennsylvania.

Adding a positive tone to the market, the U.S. government and Swiss bank UBS AG initialed agreements to settle their tax evasion dispute, ending weeks of tough negotiations between the two sides. The U.S.-listed shares of the bank rose 2 percent to $15.00.

Retailer Macy's Inc shares added 3 percent to $15.94, after posting better-than-expected earnings and raising its outlook.

The Dow Jones industrial average <.DJI> was up 127.19 points, or 1.38 percent, at 9,368.64. The Standard & Poor's 500 Index <.SPX> was up 12.69 points, or 1.28 percent, at 1,007.04. The Nasdaq Composite Index <.IXIC> was up 31.27 points, or 1.59 percent, at 2,001.00.

Before the bell, the Commerce Department said that the U.S. trade deficit widened less than forecast in June on exports gains, which were spurred by a pick-up in global demand. The gap increased 4 percent to $27 billion from $26 billion in May.

U.S. stocks fell Tuesday after a prominent banking analyst questioned the sector's recent gains and industry fundamentals. An unexpectedly large drop in wholesale inventories also raised worries about a recovery, but the broader S&P 500 is still up 47 percent from its closing-low set on March 9.

(Editing by Padraic Cassidy)