The S&P 500 and Dow Jones Industrial Average cruised toward another pair of closing records Tuesday, after solid earnings and upbeat consumer data gave investors a fresh dose of economic optimism.

The Dow added 0.3% and the S&P 500 gained 0.6%, putting both benchmarks on pace to top Monday’s record closes. The Nasdaq Composite gained 0.9%, putting it in reach of a new record as well.

Earnings...

The S&P 500 and Dow Jones Industrial Average cruised toward another pair of closing records Tuesday, after solid earnings and upbeat consumer data gave investors a fresh dose of economic optimism.

The Dow added 0.3% and the S&P 500 gained 0.6%, putting both benchmarks on pace to top Monday’s record closes. The Nasdaq Composite gained 0.9%, putting it in reach of a new record as well.

Earnings season so far has beaten investors’ expectations and helped lift stocks out of a September slump. United Parcel Service powered both the Dow and the S&P 500 after the delivery company topped analysts’ estimates.

Investors have been buoyed by strong figures from major banks, consumer companies and manufacturers. Meanwhile, jitters about the labor market and inflation have somewhat given way to optimism about a recovering economy. 

Consumer confidence rose last month, halting a three-month decline, according to the Conference Board. The latest homes sales figures from the Commerce Department also highlighted a step-up in purchases across the country, topping analysts’ projections.

Now investors are turning their attention to the tech industry. Tech behemoths MicrosoftTwitter and Google parent Alphabet, as well as Robinhood Markets and Visa, are set to report earnings after markets close. They all rose in morning trading.

“Covid numbers have crested, the economic data has been pretty good, and the early read on third-quarter earnings is positive,” said David Donabedian, chief investment officer at CIBC Private Wealth. “The bottom line is this is still a buy the dips market.”

Of the 144 companies in the S&P 500 to report quarterly earnings so far, 81% have topped analyst’s estimates, according to FactSet. Companies across the index are currently projected to grow third-quarter earnings by 33% from a year earlier.

UPS gained 7.7% after the delivery company reported that it continued to make money despite shipping fewer packages. General Electric rose 2.2% after it said cost-cutting efforts had offset lower-than-expected sales.

Some reports disappointed investors. Facebook, which was among the first of the major tech firms to report third-quarter earnings, said late Monday that changes to Apple‘s privacy rules had hit sales growth. Shares slide 2%.

Shares of Lockheed Martin fell 10% after the aerospace company posted a drop in profit early Tuesday. 

In other corporate news, DraftKings rose 5.8% after the betting company said it was withdrawing its takeover plan for London-listed Entain.

Facebook whistleblower Frances Haugen called for new regulation to require social-media firms to disclose action against misinformation and hate speech.

Tech firms are likely to remain attractive to investors despite the trend of fewer people working from home and the risk of increasing regulation, Mr. Donabedian said. 

“They are battleships—they just continue to post very strong revenue and earnings growth,” he said. 

The yield on the benchmark 10-Year U.S. Treasury note was roughly flat at 1.635% Tuesday versus 1.634% Monday. Bond prices and yields move in opposite directions. 

Overseas, the pan-continental Stoxx Europe 600 rose 0.6%. In Japan, the Nikkei 225 rose 1.8%, while in Hong Kong, the Hang Seng Index dropped 0.4%. In mainland China, the Shanghai Composite Index edged down 0.3%. 

Google parent Alphabet and other tech companies are set to report earnings after markets close Tuesday.

Photo: Cayce Clifford for The Wall Street Journal

Write to Will Horner at william.horner@wsj.com

Corrections & Amplifications
Lockheed Martin reported earnings Tuesday. An earlier version of this article incorrectly referred to the company as Lockhead Martin. (Corrected on Oct. 26.)

Chinese property developer Modern Land failed to repay a $250 million dollar bond that matured Monday, adding to a string of missed payments by the country’s real-estate companies.