Though the markets have been up strongly this year, your investment portfolio may have a few lemons in it. By using the tax strategy of tax-loss harvesting, you may be able to turn those lemons into lemonade. Here are some tips:

Tip #1: Separate short-term and long-term assets. Your assets can be divided into short-term and long-term buckets. Short-term assets are those you’ve held for a year or less, and their gains are taxed as ordinary income. Long-term assets are those held for more than a year, and their gains are taxed at the lower capital gains tax rate. A goal in tax-loss harvesting is to use losses to reduce short-term gains.

Example: By selling stock in Alpha Inc., Sly Stocksale made a $10,000 profit. Sly only owned Alpha Inc. for six months, so his gain will be taxed at his ordinary income tax rate of 35 percent (versus 15 percent had he owned the stock more than a year). Sly looks into his portfolio and decides to sell another stock for a $10,000 loss, which he can apply against his Alpha Inc. short-term gain.

Tip #2: Follow netting rules. Before you can use tax-loss harvesting, you have to follow IRS netting rules for your portfolio. Short-term losses must first offset short-term gains, while long-term losses offset long-term gains. Only after you net out each category can you use excess losses to offset other gains or ordinary income.

Tip #3: Offset $3,000 in ordinary income. In addition to reducing capital gains tax, excess losses can also be used to offset $3,000 of ordinary income. If you still have excess losses after reducing both capital gains and $3,000 of ordinary income, you carry them forward to use in future tax years.

Tip #4: Beware of wash sales. The IRS prohibits use of tax-loss harvesting if you buy a “substantially similar” asset within 30 days before or after selling it at a loss. So plan your sales and purchases to avoid this problem.

Tip #5: Consider administrative costs. Tax-loss harvesting comes with costs in both transaction fees and time spent. One idea to reduce the hassle is to make tax-loss harvesting part your annual tax planning strategy.

Remember, you can turn an investment loss into a tax advantage, but only if you know the rules.