“
If you reinvest dividends throughout the tax year and thus increase the number of shares...

eg buy 1000 shares in April at price A, have 4 dividends through the year total 40 extra shares.

Sell 500 shares of 1040 total next March at price B to use up allowance.

Is gain simply 500 x (price A - price B) minus costs?

Originally posted by **talexuser**
”
No, it is basically 500/1040ths of the purchase price of all the 1040 shares. The purchase cost of all the 1040 shares includes the cost of the first 1000 which were acquired at price 'A' per share, and the cost of the next 10 and the next 10 and the next 10 and the next 10 which were bought with dividend proceeds and acquired for prices 'W', 'X', 'Y', 'Z' at the time of spending the dividend proceeds on them.

From knowing the total cost of ALL the 1040 shares (which is greater than what you paid for just the first 1000, because it includes what you paid for the last 40 too), you can divide the total cost by 1040 and see the price per share. Say that's 101p a share. It might be more than the 100p or whatever that was Price A. Forget Price A. You are looking at what did you pay, on average, for ALL the shares. Which includes the shares that were purchased out of dividend proceeds.

When you sell 500 shares, you are selling shares that cost £505 so you take the £505 and the £10 sale costs off the proceeds you got for selling the 500 shares (maybe £600) and you make your £85 profit.

OK, in the example above, the 540 shares had an average cost of 101p each or £545.40.

Over the course of the year you will be buying 10 more shares with your first dividend proceeds at price R, then another 10 a few months later at price S, then another 10 at price T, then another 10 at price U. So in total the cost of your pool of 580 shares will be £545.40+ (10xR) + (10xS) + (10xT) + (10xU).

Maybe all those shares R, S, T, U were acquired with an average cost of 105p per share. So the 40 extra shares cost £42 on top of the 540 shares you had at the beginning of the year which cost £545.40, so your total pile of 580 shares cost £587.40, which is 101.276p each, and you will use that cost per share when selling the next slice.

“
Next year you so the same at the end of the tax year. Presumably the 500 sold are calculated from price A.

”
No, we forgot price A quite early on because it is no longer relevant. You are holding 580 shares which cost £587.40, which is 101.276p a share.

If you choose to sell 500 of them: the cost of the shares sold, at 101.276p each is £506.38. Or another way of looking at it is that you are selling 500/580ths of something that cost £587.40 which is £506.38.

“
You now have 80 shares left from 2 years of dividends.

What is the calculation for their starting price, the average from price A to current?

”
As you just calculated, you had 580 shares costing £587.40, and if you sold 500 of them with a cost of £506.38, the 80 you have left must have cost £81.02.

Which would make sense given we know they cost £101.276p each because we have been tracking the overall average price of the pool as we add cost when buying and remove cost when selling.