By Anora Mahmudova and Barbara Kollmeyer, MarketWatch

NEW YORK (MarketWatch) -- The U.S. stock market ended Tuesday's choppy session posting marginal gains. But equally important, Tuesday's moves marked the first time the market closed mostly flat after registering wild swings in the previous five sessions.

Stocks rose sharply in early Tuesday trading, boosted by better-than-expected earnings, but the main benchmarks trimmed gains by late afternoon, and briefly dipped into the red.

The S&P 500 (SPX) closed 3 points, or 0.2%, higher at 1,877.70. The benchmark index still sits below its 200-day moving average, after breaching the level on Monday for the first time in nearly two years.

The Dow Jones Industrial Average (DJI) swung between gains and losses and closed down 5.9 points at 16,315.19, the lowest level since April 5. The Nasdaq Composite (RIXF) gained 13 points, or 0.3%, to 4,227.7.

The Russell 2000 (SPX) outperformed its large-cap counterpart and closed up 12 points, or 1.2%, at 1,061.60.

Stuart Freeman, chief equity strategist at Wells Fargo Advisors, urged investors to keep volatility in perspective and not be scared of daily moves, saying volatility is normal in equity markets. Freeman also advised investors to consider investment horizons and be well diversified.

Investors welcomed strong earnings results from Citigroup Inc. and Johnson & Johnson, which earlier outweighed downbeat German sentiment data that hit equities across Europe.

Vote here: Does this stock slump have further to go?

Earnings in focus: Citi (C) shares popped up 3.2% after third-quarter profit and revenue rose from the year-earlier period. Citi also plans to pare back from retail banking in smaller countries.

Meanwhile, Wells Fargo & Co. (WFC) shares slipped 2.7% even as the bank's quarterly profit met expectations but revenue beat estimates.

Shares in Southwest Airlines Co. (LUV) rose 3.9% and Delta Air Lines Inc. (DAL) rallied 6.1% as concerns about a global Ebola pandemic eased.

Domino's Pizza Inc. (DPZ) jumped 11% after the chain delivered better-than-expected results.

Among other stocks in focus, Versar Inc. (VSR) surged 17%. Its PPS unit makes hazmat suits and mobile decontamination shelters. Other stocks linked to concerns over the Ebola virus continued a pattern of pushing higher.

Lakeland Industries Inc. (LAKE) and Alpha Pro Tech Ltd. (APT) fell more than 26%, after soaring during the previous few sessions on Ebola fears. Ebola stock trading volumes should raise red flags

Read about today's notable stocks in Movers & Shakers column.

Other markets:European stocks fell after a key sentiment survey out of Germany turned negative. Burberry Group PLC shares dropped after the luxury-goods maker posted a rise in sales, but cited unfavorable foreign exchange headwinds and Chinese weakness. U.K. inflation fell to a five-year low. The European Court of Justice has begun holding a hearing on the European Central Bank's Outright Monetary Transactions bond-buying program.

In Asia, the Nikkei 225 index sank 2.4%, falling below the 15,000 level and skidding to two-month lows.

Crude-oil prices(CLX4) drifted lower, and gold(GCZ4) inched up, while the dollar ((USDJPY) pulled back from an overnight slip against the Japanese yen.

Subscribe to WSJ: http://online.wsj.com?mod=djnwires