you bought 5 different parcels, made up of X number of XYZ bought at those prices. each share is its own asset.
you sold X number at $4.
you have sold WHATEVER SHARES YOU WANT AT $4.
there is no rule which says which shares you sold - you sold any combination of any of the shares you owned - you decide, and naturally the more different shares you choose, the more calcs you need to do.
eg. sold 100 at $4.
this can be all from one purchase, a mix of any of your purchases - your choice.
20 from each parcel bought, or 10 from the bottom parcel, 90 from the top parcel - whatever.
again youll have either 1 calc to do or up to 5, depending on which you decide you sold.
the most important thing - KEEP RECORDS - to confirm at later times what you deemed to have sold.