By Anora Mahmudova and Carla Mozee, MarketWatch

Main indexes record monthly and quarterly losses

The S&P 500 ended Tuesday's volatile session slightly higher, as investors were whipsawed by the vagaries of Greece's episodic debt negotiations.

However, Tuesday's positive finish for stocks wasn't enough to overcome Monday's Greek-inspired rout, which has left most of the main stock indexes with quarterly and monthly losses.

The S&P 500 ended the quarter lower, snapping a nine-quarter winning streak. Monthly losses for both the S&P 500 and Dow industrials--2.1% and 2.2% respectively-- were the worst since January. At the half-year mark, the S&P is 0.2% higher, while the Dow is 1.1% lower.

News from Greece dominated the trading day. Markets appeared to rise on reports that Greece proposed a two-year deal using the eurozone bailout fund, according to The Wall Street Journal (http://www.wsj.com/articles/some-greek-banks-to-open-for-pensioners-1435653433).

Questions remain about the future of the southern European country as it heads toward a referendum (http://www.marketwatch.com/story/yay-or-nay-greeces-referendum-will-be-complicated-2015-06-29) set for July 5 that is being framed as a vote on whether the European country should stay in the eurozone. Greece missed a Tuesday deadline to repay 1.54 billion euro ($1.71 billion) to the International Monetary Fund, the same day its bailout program expired.

Europe's headlines created a rocky ride for investors.

"Implied volatility levels are not that high, but certainly elevated from the low levels we have seen so far this year and we expect volatility to remain at those levels for the next few weeks," Kepner said.

Marc Kepner, managing director of sales and trading at Themis Trading, said today's moves were due to market grasping for any good news.

"For a while markets were pricing in a resolution to the Greece debt crisis, but Monday's turn of events brought a great deal of uncertainty," Kepner said.

The S&P 500 ended 5.45 points, or 0.3%, higher at 2,063.0. Over the month, nine of 10 main sectors recorded losses, with utilities suffering the most. The sector declined more than 6% over the month.

Over the past quarter, utilities also led the losses, down 6.7%, while health-care stocks finished with a 2.4% gain. The Dow Jones Industrial Average added 22.82 points, or 0.1%, to 17,619.17.

Meanwhile, the Nasdaq Composite gained 28.40 points, or 0.7% to 4,958. The tech-heavy index booked a 1.6% monthly loss, but finished the quarter 1.8% higher and is up 5.3% so far this year.

Here's what technical analysts are watching after the year's biggest selloff (http://www.marketwatch.com/story/heres-what-technical-analysts-are-watching-after-the-years-biggest-selloff-2015-06-30)

"This is a holiday-shortened week and with Greece news driving the markets, we expect some erratic trading. The concern here is the kind of pullback we last saw in October. Traders will be watching the 2,040 level on the S&P 500 very closely," said Frank Cappelleri, executive director at Instinet LLC.

Data: Investors digested a trio of mixed economic reports. U.S. house prices rose in April, supported by the spring sales market, with gains in all the cities tracked by the Case-Shiller 20-city composite index released Tuesday, however the gain fell short of expectations.

Chicago PMI rose in June but remained under the 50 level, indicating a slight contraction in conditions. That is the fourth month below 50 this year.

Separately, U.S. consumer confidence jumped in June, according to an index released by The Conference Board on Tuesday, topping forecasts.

Stocks to watch: Michael Kors Holdings Ltd. (KORS) fell for a sixth session in a row and closed down 3.9%. It is the worst-performing S&P 500 component in the second quarter. The fashion retailer last month warned that first-quarter results are likely to disappoint.

Pentair PLC (PNR) shares jumped 6.7% after Trian Fund Management L.P. revealed a 7.24% stake in the companies. Trian is asking the maker of pumps and valves to buy rivals and consolidate fragmented market.

For more on today's notable movers read Movers & Shakers column (http://www.marketwatch.com/story/microsoft-apollo-education-conagra-in-spotlight-2015-06-29).

Other markets: Chinese shares rebounded from heavy selling (http://www.marketwatch.com/story/china-shares-fall-as-rest-of-asia-is-calm-2015-06-29) seen Monday, pulling the benchmark back from losses that had put it in bear-market territory. Japan's Nikkei ended higher by 0.6%. But European stocks extended their losses (http://www.marketwatch.com/story/european-stocks-mired-in-red-with-greek-default-expected-2015-06-30) as investors continued to wrestle with Greek-related worries.

Oil prices (http://www.marketwatch.com/story/oil-prices-rise-as-iran-nuclear-talks-enter-deadline-day-2015-06-30) settled 2% higher at $59.47, ending the first half of the year with a hefty gain. Gold futures (http://www.marketwatch.com/story/gold-edges-lower-as-hopes-rise-for-last-minute-greek-deal-2015-06-30) fell 0.6%, to settle at $1,171.80 and marked a loss for the first half of the year.

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