I find myself doing a lot of trading in the same stock. I may buy 100 shares, sell 50, buy 200 more, then sell 100. However, I'm not sure whether the IRS requires me to use first-in, first-out or last-in, first-out when accounting for my cost basis. Can I choose whichever is the most advantageous in a particular situation, or am I required to be consistent?

-- John Tucker

John,

With year-end tax selling just around the corner, many investors will be looking to unload some shares. And knowing which shares to sell can save you tons of tax dollars.

While the first-in, first-out method and the last-in, first-out method are perfectly acceptable, your tax bill may be better off if, instead, you specifically identify which lots to sell. Granted, specific lot identification can be a paperwork nightmare, but it can leave more money in your pocket.

With the first-in-first-out method, commonly known as FIFO, the first shares you purchase are the first shares you sell. Last-in, first-out, or LIFO, means the last shares you purchase are the first shares sold. Specific-lot identification, on the other hand, means you choose which shares to sell, regardless of when they were purchased. Identifying lots may be more advantageous in most cases because it allows you to more actively minimize your taxable gains. But you can switch methods at any time. You're not stuck with the first method you use.

Let's assume you're in the 39.6% federal tax bracket and you bought the following 50-share lots of

IBM

(IBM) - Get Report

.

With the stock around $114, you've decided to sell 50 shares. But which 50 shares should you sell?

Your first inclination may be to sell the April lot, since you've held it the longest, and it will qualify for the 20% long-term capital gains rate. If you sold that lot, your gain would be $1,350 ($5,700 - $4,350). At the 20% rate, you'd owe Uncle Sam about $270.

Even though the original cost of the November lot is higher, selling it will not minimize the tax hit because that sale would not qualify for the 20% rate. You'd be taxed at your 39.6% ordinary income tax rate. In that case, you'd owe Uncle Sam around $317 (39.6% of your $800 gain).

But what about the March lot? Since you bought the shares for more than their current value, you would not owe a dime. Better still, you would have a $350 ($6,050 - $5,700) loss to use to offset future gains.

If, on the other hand, the fair market value of the stock rises to $135, consider selling the March lot because your tax bill would only be $277

($6,750 - $6,050) x 39.6%. Even with the 20% long-term rate, selling the April lot still would cost you $480

($6,750 - $4,350) x 20%.

Regardless of which lot you sell, it's important to inform your broker in writing when you're identifying specific lots. Otherwise, he will sell whichever lots he chooses. Then you need written confirmation that your specified lots were sold. That confirmation will act as your proof for the

Internal Revenue Service

, so keep it with your records.

TheStreet Recommends

Remember, your brokerage firm is not required to report your cost basis to the IRS. Firms that keep track are doing it as a customer service. But the taxable amount of the sale does not show up on your Form 1099, reminds Maggie Doedtman, a senior tax-research and training specialist at

H&R Block

in Kansas City, Mo. Only the fair market value of the shares sold is reported. In our example, only $5,700 would be on your brokerage statement, representing the current value of the 50 shares you sold.

And there are some brokers who will tell you that their systems are not set up to allow for specific lot identification, which in this day and age is lame. But don't get nervous. You can still do specific-lot identification; you just need to keep scrupulous records.

"Your records are most important. Your brokerage records are helpful, but

brokerages do not have total control," says Bill Fleming, director of personal financial services for

PricewaterhouseCoopers

in Hartford, Conn. Assuming the numbers you report on your tax return are reasonable and well documented, they will override any numbers reported (or not reported) on your brokerage statements.

Factoring in Funds

Mutual funds are a bit different. If you choose one method for selling shares of a particular fund, you must stick to that method. So if you've been selling your shares of Fund XYZ on a FIFO basis, you can't switch to specific-lot identification for your next sale. You can, however, use different selling methods for different funds.

Fund shareholders also have an additional method -- average cost. This method determines your cost basis by dividing the total cost of all the shares you own by the total number of shares. But if you use this method, you must attach a written statement noting your election to

Schedule D

-- Capital Gains and Losses

of your tax return.

For all other methods, whether you're a stock or a fund investor, you don't have to file anything with the IRS if you use more than one method or even switch methods. It's just imperative that you keep your personal records in intact.

Check out

Publication 550

-- Investment Income and Expenses

for more information.

Send your questions and comments to

taxforum@thestreet.com, and please include your full name. Tax Forum appears Tuesdays, Thursdays and Saturdays.

TSC Tax Forum aims to provide general tax information. It cannot and does not attempt to provide individual tax advice. All readers are urged to consult with an accountant as needed about their individual circumstances.