Losing money in the stock market is painful, but the tax code does allow you to use those losses to your advantage. When you sell a stock for less than you paid for it, you have a realized capital loss that can offset capital gains you earned during the year. If your losses exceed your gains, you can deduct up to $3,000 of the net loss against your ordinary income in a single year. Any remaining loss carries forward to future years until it is used up. This strategy, sometimes called tax loss harvesting, is a common planning technique that investors use toward the end of the year.