True, you only take a gain or loss if you sell, with one exception. You can only take the loss if you don't buy more shares in a 30 day window. If you do, then the shares you buy back are considered a wash sale. If you buy less shares than you sold, then you can take the difference as a loss. Flip side...all sales that result in a gain must be recognized. :) Don't you love the IRS.