The roaring stock market rally that President Trump loves to boast about has left half the country behind.

Only 54% of Americans have money invested in the market, either through individual stocks, mutual funds or retirement plans like a 401(k), according to a Gallup survey in April.

That's down from 65% just before the Great Recession -- meaning that millions of people have sat out one of the longest bull markets in history. The S&P 500 has nearly quadrupled, and lately the Dow is setting record highs day after day.

Lower-income Americans, many of whom by definition don't have extra money to invest, can't feel that red-hot stock market. Stock ownership is just 21% among people with household income of less than $30,000 a year, according to Gallup.

The rally is very real for wealthier Americans: 89% of those who make at least $100,000 own stocks. And, incredibly, the richest 20% of Americans owned 92% of all stocks in 2013, according to research by NYU economist Edward Wolff.

One reason so few Americans are invested is that a third of workers don't have access to a 401(k) or other retirement plan.

"If you're a coal miner in West Virginia without a 401(k) or stock market exposure, you don't care about all-time highs," said Andres Garcia-Amaya, global market strategist at independent wealth management firm Zoe Financial.

"It's easy for us sitting in New York to look at the market and say everyone is doing well. The reality is that a huge portion of the population is not participating in this," he said.

You wouldn't know it from Trump's tweets. He regularly brags about stocks, which have soared since his election last fall.

Related: These charts show how the Trump economy is really doing

Of course, stocks aren't climbing just because of Trump. The economy is in good shape, which has lifted corporate profits. Unemployment is at a 16-year low, while job openings are the highest in 15 years. A stronger labor market helps even Americans who aren't invested.

And to be fair, President Obama and other presidents trumpeted the stock market, too. Obama mentioned the market in several State of the Union addresses, although he did it in the context of longer-term gains, not day-to-day records.

Younger people are less likely to benefit from the market's rise. Just 31% of people ages 18 to 29 owned stocks on average between 2009 and 2017, according to Gallup. That's down from 42% during the eight years before.

By comparison, nearly two-thirds of Americans between 30 and 64 years old own stocks.

Related: Trump is playing with fire by obsessing over stocks

It makes sense that younger Americans are less likely to have money in the market because they have accumulated less wealth early in their careers.

Millennials are also among the groups who tend to have less access to 401(k) or similar retirement plans, according to research from Pew Charitable Trusts.

Overall, more than a third of workers don't have access to either a defined benefit or defined contribution plan that is sponsored by their employers, the research found.

Young Americans' declining participation in the market may also reflect lingering scars from a formative experience of their youth: the 2008 financial crisis, which crushed countless innocent investors.

"Some younger Americans may look at what happened in 2008 and conclude, 'This isn't for me. It's too risky,'" said David Joy, chief market strategist at Ameriprise Financial.

Ironically, that same risk aversion has helped keep the market chugging higher. Persistent skepticism about the bull market has prevented the type of euphoria that in the past has inflated a bubble that ended in tears.

"It's one of the reasons this market has been able to carry one: There have been so many skeptics," said Garcia-Amaya.