Buying The Same Stock Multiple Times

Hello there, I have a question. Since I bought the same stock 3 different times at 3 different prices then how does it work when I decide to sell them? I have notice that Trading 212 combine all the 3 purchases in 1 doing an average price of purchase. I understand the logic behind this and I agree that in the end it is the same, but I have a question regarding taxes on it.

I do an example. If I buy stock X at 12.1 (quantity 10), 13.4 (quantity 10) and 14 (quantity 10) what happens when I sell it at 13.6 (quantity 10)? I mean if we average the price it is like I bought those shares at an average price of 13.17 and, therefore, I have made a gain on the sale and pay taxes on it. However, if the 3 purchases where kept separately then I would consider it as a loss and not pay taxes on it (bought 14 - sold at 13.6).

Can someone explain?

Thank you.

FIFO rule take place when it comes to tax, there are other topics explaining that in detail on forum as well just search “FIFO” @Ados83

It depends on the tax rules in your country. A few counties operate a FIFO system. Many others, such as UK, operate with the average cost as the basis price (unless you buy and sell on the same day, or sell and rebuy within 30 days). It is impossible to answer your question unless we know the country in which you pay tax and the dates of your purchases and the sale.