Paying taxes on investment gains is an unfortunate reality of successful investing.

Writing a check to the IRS is never fun, but the truth is that a large tax bill typically means you booked a significant return from those investments. You only pay money if you make money.

If paying capital gains taxes is an unpleasant side effect of strong performance, then harvesting losses is a silver lining during bear markets.

Year-to-date losses in 2022 may have you feeling stuck, but it's not too early to focus on minimizing taxes.

In an average year, most investors (and advisers) wait until November or December to harvest losses. But given the steep decline in stock prices — the S&P 500 has lost 20% from its early January peak — there's no need to wait.

This is especially true if you have escaped the herd mentality and have a positive view on equities between now and year-end (as we do). If stock prices rise in the next four to five months, the value from loss harvesting will diminish between now and then.

What then is the best method to realize losses efficiently? First, make sure you are mindful of the wash-sale rule, a law that disallows any tax loss if you buy back the same security within 30 days after selling.

The simplest strategy is to sell your holdings with the largest losses since purchase date and leave the proceeds in cash for 30 days. You can then buy back the original holdings, assuming you still consider them attractive. The risk here is that the investments you sold end up rallying during the 30 days after sale and you miss out on legitimate gains.

To remove that risk, it's common practice to own a proxy during the 30-day waiting period. You might, for example, sell Amazon stock and replace it with a technology or consumer discretionary fund as a temporary holding. If, however, your replacement rises during those 30 days, you will realize a short-term gain upon selling it. Short-term gains, of course, are less favorable for tax purposes so the proxy strategy could backfire.

A better strategy is to first identify your most attractive "sell candidates," then implement the selling incrementally over a few months. You might have six investments with significant unrealized losses. You can sell two of them and be only slightly overweight cash for 30 days, then repurchase those holdings. Then, sell the next two and repeat as needed. Think of this as a similar approach to dollar cost averaging, but from a tax perspective.

You may be wondering how investors would have any gains to offset this year considering market performance. The answer is related to the previous year's tax strategy. Since clients generally prefer to defer losses whenever possible, it's not unusual to wait until January to realize gains, thereby pushing tax consequences out an extra 12 months.

This is the approach we took in our investment portfolios early this year. It worked in the sense that we sold highly appreciated stocks in favor of companies with lower valuations that have weathered this downturn better than others. But it also meant our clients started 2022 with realized gains.

It can be a delicate balance when it comes to tax loss harvesting. Realizing losses does not add value if done at the expense of investment returns. But if your income and tax bracket are high, doing it right can make a world of difference.

Ben Marks is chief investment officer at Marks Group Wealth Management in Minnetonka. He can be reached at ben.marks@marksgroup.com. Brett Angel is a senior wealth adviser at the firm.