The hit an all-time high on Tuesday and tied the record for the longest bull market ever as investors bet that the strengthening economy and booming corporate profits seen under President Donald Trump's first two years would continue, despite recent trade battles.

The broad index rose 0.2 percent and reached an intraday record of 2,873.23, led by consumer discretionary and industrial. The S&P 500 surpassed 2,872.87, a high reached on Jan. 26. The index failed to post a record close, however, ending the session at 2,862.96.

The bull market turns 3,453 days old on Wednesday, which would make it the longest on record by most definitions. On Tuesday, it tied the one that ran from October 1990 to March 2000. The S&P 500 has risen more than 300 percent since hitting its financial crisis bottom on March 9, 2009. For the year, the index is up more than 7 percent.

"Nobody believed in this bull market and they still don't," said Marc Chaikin, CEO of Chaikin Analytics. Lots of people "were left so scarred by the crisis they didn't get on board."

Chaikin also said the bull run can continue: "We have an economy that is not overheated and rates are still low. Couple that with the fact that people keep finding reasons to hate this market, that is a perfect storm for more gains."

The Dow Jones Industrial Average gained 63.6 points to close at 25,822.29, just 3 percent below a record high, with Intel and Goldman Sachs leading the index. The Dow Transports hit its first intraday record high since Jan. 16.

The Nasdaq Composite outperformed, rising 0.5 percent to 7,859.17 as Micron and Netflix rose. The Nasdaq also closed less than 1 percent from reaching an all-time high. The Russell 2000, which is made up of small cap stocks, reached a record high.