Contrary to the WIKI link, I did not use the same number of shares for each purchase. This is all hypothetical for the purpose of getting the math right. Let's use acme for the name of an asset. Beginning with the second purchase calculate DCA as follows: (total cost) / (number of shares). For each new purchase repeat the previous formula and so on.
At this moment in time:
I have 36 shares of acme at a DCA of [imath]71.09, making the total value of ((36 shares) x (DCA of[/imath]71.09)) = $2,559.24.
Suppose that I sell 5 shares of acme @ [imath]100.00/share making the total value of the sale[/imath]500.00.
Now the value of the remaining shares is ([imath]2559.24 -[/imath]500.00) = $2059.24
STARTING HERE is where I don't know if the math is correct. The remaining 31 shares of acme have a value of $2059.24.
So is the new DCA

((current value of [imath]2059.24) / (31 shares)) =[/imath]66.43?
Assuming the previous math is correct, let's calculate the profit on the sale: using the sale price less the DCA purchase value before the transaction as expressed here: ((sale price [imath]500.00) - (5 shares @[/imath]71.09 [which equals [imath]355.45])) =[/imath]144.55.
The logic looks good to me, but am I making incorrect assumptions?
Your input will be greatly appreciated.
regards, YeOldeStudent
EDIT to correct parentheses .