Since every seller is matched with a buyer, how can everyone make money trading with each other? The only way additional money comes into the system is if a new investor appears, or a stock pays dividends.
Different people value resources differently overall and also differently over time. Trading a resource you don't value as much to someone who does value it for something you value leads you both to be better off.
In a very simple form, if you're a fisherman you may have a surplus of fish, much more than you can eat before they go bad. Fish is not worth much to you, but maybe you need cloth for sails, the someone in the village collects and mends and sews cloth. They have a lot, but need food. Trading fish for cloth benefits you both.
Money is just an abstraction to smooth trades between people for resources they need. Scale to whatever level you want.
But we're talking about stocks, not fish. You can do four things with stocks: exert control over the company, collect dividends, lend it, and sell it. Funds generally aren't buying so they can create wealth by exerting control. Lending and selling are both zero-sum.
Why? Lending is just giving people money they value more now than you do, so much so they agree to pay back more later. The utility at the current time of that money is better than the utility later for the lendee, and the opposite is true for the lender (they will happily forego some money available now for more money available later).
If I take a loan out to buy a car which lets me find a better job because I can travel for efficiently, and I get a better job that pays more which allows me to much more money and paying back that loan is itself even easier, is that transaction zero-sum when examined over time?
Trading is only zero-sum at very small time scales. Over longer times scales, the stock market is not a closed system. Traders who run out of money will either exit the market entirely, or find more money from somewhere else. That money comes from either economic profits, or the economy's money-creation process. In the US economy, that process is fractional reserve banking[0].
Apple the company issues stock. They are the seller, and some investor is the buyer. Apple uses the money to invest in operations, and the stock goes up over time. Who lost?
Forget about stocks - this is the whole point of trade in general. People have different resources and different needs, time horizons, risk tolerance etc., so the default assumption should be that voluntary trade is positive sum - just like Ford selling a car is positive sum even though there is a buyer and a seller.
Apple issues stock at $200/share. Bob buys one share. Apple is now $200 richer, Bob is $200 poorer.
Later, Apple goes up to $300/share. Bob sells his stock to Charlie. Bob is now $100 richer, Charlie is $300 poorer. Total change: zero.
Apple is more valuable and that (probably) means wealth was created, but that increase in wealth comes from Apple doing things, not from the trading.
Non-stock trading creates wealth because different people value things differently. A sandwich is worth less to Subway than it is to me, so total wealth increases when I pay them for a sandwich. But stocks don't really work that way. Unless you're buying a stock to exert control over the company, the only thing you're doing with it is using it to make money money. If you're making money by selling at a higher price later, then that comes from someone else paying that higher price, and it's all zero-sum.
I was responding to "Pension funds, banks, HFT firms can all make money while trading with each other." I readily accept that economic activity is not zero-sum, creates wealth, and that trading stocks can help enable that. But just trading by itself doesn't make money.
"Making money" at the same exact time does not have to be the goal. Bob might want more liquidity and lower volatility now, so he wants US dollars (USD) from Charlie. Charlie might want less liquidity now, but wants to bet on $300 worth of AAPL will have more purchasing power at some point in the future than $300 of USD.
Everyone can make or lose money depending on whether the value of the stock goes up or down and whether the participants own the stock or are borrowing it (short/negative ownership).
You mention two factors that can introduce new capital into the system, new investors and dividends, but seem to imply they are negligible or can be ignored... on the contrary those two factors are quite significant contributors and according to some theories dividends are the ultimate and total source of value in the stock market:
The value of the stock going up doesn't mean everyone makes money. Everybody's stuff is worth more on paper, but they can't convert it to money unless they sell it, which means someone else had to buy it and convert their money into stock. The total amount of money remains constant.
I didn't mean to imply that those two factors are negligible. Only that they're not part of "trading," i.e. trading is zero-sum but these make the system as a whole not zero-sum. I was responding to "Pension funds, banks, HFT firms can all make money while trading with each other." Which suggests that you don't need other things for everyone to make money, it can happen purely by trading.
If you just mean a closed group of people are passing around stock among each other, never able to collect a dividend or add new participants, then sure such a system would not be positive sum.
But the participants listed, pension funds, banks, HFTs, etc... are not just trading with each other in a closed system. These participants can all trade with each other and all gain from one another precisely because there are dividends paid out, and new participants.
Pension funds need to liquidate or rebalance their portfolio on a short notice or daily basis, so they benefit from trading with HFTs who can take on virtually arbitrary inventory and quickly hedge it, charging a very small and implied fee (usually from a spread or some other implied mechanism), who in turn offload that inventory onto a bank or another pension fund, etc etc...
These participants can all benefit from one another's involvement in the market instead of competing against each other.
In a very simple form, if you're a fisherman you may have a surplus of fish, much more than you can eat before they go bad. Fish is not worth much to you, but maybe you need cloth for sails, the someone in the village collects and mends and sews cloth. They have a lot, but need food. Trading fish for cloth benefits you both.
Money is just an abstraction to smooth trades between people for resources they need. Scale to whatever level you want.