The opinions expressed by columnists are their own and do not necessarily represent the views of Townhall.com.

Donald Trump says the problem in the United States is that "we don't win anymore." Trade is his favorite example, based on our longstanding trade deficit. But in one big area, America is a big global winner, year after year. That little-known fact exposes the basic, fatal error in Trump's lament.

What he overlooks is that this country is one of the most inviting places for people abroad to invest their money. Since 2001, foreign direct investment in the United States has more than doubled. Last year, foreigners bought $11 trillion worth of stocks.

They also wanted other assets -- nearly $1.4 trillion in U.S. Treasury bonds and almost $1.2 trillion in corporate bonds. We may run a deficit on the trade side, but we consistently boast a surplus on the capital side. That's a good thing.

What explains it? One attraction is the strength of our institutions. We offer advanced financial markets, secure property rights, the rule of law, political stability and low levels of corruption in both the private and government sectors.

This year, the World Bank ranked the U.S. seventh in the world for "ease of doing business." That gives us a leg up on almost every other country, including such feared competitors as Germany (15), Japan (34), Mexico (38) and China (84). These indicators, the World Bank says, "have huge long-run implications for an economy's health, performance and growth."

Another lure is the comparative vigor of the U.S. economy. Since 2002, our GDP growth has consistently outpaced that of the European Union and Japan. Faster growth heightens the advantages of being located in the world's biggest market. The dominant role of the U.S. dollar also helps. It is the closest thing to a global reserve currency, held in large quantities by foreign governments.

People in much of the world save more of their income than we do, which means we buy more stuff than they do. That makes the U.S. a great place to sell cars, shoes, toys and computers.

One fact that Trump and Bernie Sander never mention is that our trade imbalance is all in goods. When it comes to services -- such as travel, banking services, royalties, legal advice and education of foreign students -- we export far more than we import. In each of the past five years, our surplus in services has exceeded $200 billion.

Services are important because they account for most of the world economy and are steadily growing. Since 2000, their share of global output has expanded from 67 percent to 71 percent, while industry and agriculture have shrunk. The same pattern is evident even in China.

The continuing stream of money from overseas keeps the U.S. capital account perpetually in surplus: Foreigners lend and invest more here than we lend and invest elsewhere. Americans benefit because foreign capital builds factories and stores, creates jobs and minimizes the cost of government borrowing.

Why is all this important? Because the inflow is a big and almost universally overlooked cause of the trade deficit. Think about it: If foreigners want to buy land or buildings or bonds in the U.S., they need dollars. To get dollars, they have to sell to Americans.

The little-known secret of international commerce is that foreigners can't invest more here than we invest abroad unless they also sell us more than we sell them. This is not a matter of academic theory. It's a matter of accounting.

The late economist Herbert Stein wrote the entry on "balance of payments" in "The Concise Encyclopedia of Economics." "A deficit in the current account is always" -- always -- "accompanied by an equal surplus in the capital account, and vice versa," he noted.

Confronting that simple fact means recognizing that the trade deficit is merely the flip side of a healthy phenomenon. If no one wanted to invest here, we'd be running a trade surplus -- and we'd regret it.

What economists at the Federal Reserve Bank of St. Louis noted in 2006 remains true today: "Capital account surpluses, and therefore current account deficits, are being driven primarily by foreign demand for U.S. assets" -- not by unfair trade practices, cheap foreign labor or currency manipulation.

Trump and Sanders see trade in terms that are simple, vivid and wrong -- as a competition in which exports are victories and imports are defeats. They think we are losing, but they don't know how to keep score.