Suppose you have $100 in savings (S), and stocks A and B are selling at $100, and you need $100 in cash now. Do you liquidate A, B, or S? You should liquidate the investment you expect will drop in "effective price."
Effective Price
I call "effective price" (I don't know what the real name is) the price of a stock after taxes. Suppose you bought a stock at $1 this year and it's current price is $100. You can sell the stock for $100 to meet your cash flow needs but your $99 gain will be taxed at the short term capital gains rate of, say, 25% = $24.75. So although you receive $100 today for the stock, you'll have to pay the IRS $24.75 come tax day so the effective price is $100-$24.75=$75.25.
A capital loss increases the effective price since it can be used to offset the capital gains of some other sale. Suppose you bought a stock at $100 and it's current price is $75. Selling the stock causes a short term capital loss of $25. You can later subtract that loss from the capital gains of a sale of another stock, effectively reducing the tax for that second sale by $25*25%=$6.25. Therefore the effective price is $75+$6.75=$81.25.
For Identical Securities, Sell The One With The Highest Effective Price
Suppose A and B are the same stock and are both selling at $100, but you bought A at $1 and B at $10 this year. Thus the effective price of A is $75.25 and B is $77.50. For simplicity assume we only need $75. Its better to sell B since your after tax profit (eg net profit) is higher. If you sell B today for the effective price of $77.50 and A tomorrow for $75.25 (assuming the price doesn't change), your net would be $152.75.
(Apparently this is standard practice: see Page 3, Paragraph 2, http://www.invescopowershares.com
/pdf/P-TES-WP-1-E.pdf)
If both stocks are selling at a capital loss it's better to sell the stock with the highest loss since the loss can be used to reduce your net taxable gains. For example, suppose A and B are the same stock selling at $100, but you bought A at $125 and B at $150 this year, which means selling A creates a $25 short term capital loss and selling B generates a $50 loss. As explained earlier the loss increases the effective price: A's effective price become $100+($25*25%)=$106.25 and B's is $100+(50*.25)=$112.50. Therefore we should sell B since it's effective price is higher.
For Different Securities With The Same Price, Sell The One Whose Price Is Expected To Drop or Stay The Same
Now take the exact same scenario except A and B are different stocks. The effective price of A and B is still $75.25 and $77.50, respectively. However, a careful analysis of the companies suggests that A is overvalued at $100 and the price is expected to fall tomorrow to, say, $50 ($37.75 effective price). If you just sold the one with the highest effective price today, B, and A tomorrow your net would be $115.25. However if you sold A because you felt it was overvalued and expected it to fall, then sold B, your net would be $152.75. So for different securities its better to sell the one whose price is expected to drop.
However if we expect the effective prices of A and B to increase then its better to obtain the $75 from savings so we can hopefully capture A and B's gains at a later date.
We don't have to care about the future when the securities are identical (eg stock in the same company) since price changes will effect those securities identically. In other words if A and B are the same stock and the price of the stock go up $10, both A and B will have the same price and their effective prices will change proportionally with the price change. So you want to sell the one with the highest effective price.
Not So Simple
Of course real situations are never this black and white. We don't really know what's going to happen to A and B, and their effective prices may influence the decision:
"If the pursuit of lower taxes affects the pre-tax return potential, then it's not clear that such an approach enhances after-tax return."
https://advisors.vanguard.com/VGApp/iip/site/advisor/researchcommentary/article/IWE_InvComETFTaxEfficiency