I know that often times the argument against holding stocks is the tax applied after selling them. But what if I have a sizable medical expense to offset the capital gains taxes? Will holding and selling stocks be a sensible option?
A large medical expense may offset the capital gains tax, but it depends on the cost of the medical bills relative to your adjusted gross income (AGI), how long you have owned the stock, and how much you sell that stock for relative to the purchase price, or cost basis.
You can deduct the portion of medical expenses greater than 10% of your AGI. So for 2017, if your AGI was $50,000, you could deduct expenses greater than $5,000. If your medical bill was $7,000, you could deduct $2,000 (the portion greater than 10%). 50k puts you in the 25% tax bracket, so this deduction would save you $500 in tax.
In this example you would sell $7,000 of stock to pay your medical bills. You first have to determine the cost basis of the stock. Say you bought the stock for $4,000 several years ago. The capital gain is what you made on the stock, so $3,000. For the 50k AGI, the capital gains rate is 15%, so you would pay $450 in tax.
You can come out ahead, however it depends on your specific situation. If your medical expenses were closer to 10% of your AGI you could deduct less. You must itemize your deductions in order to deduct medical expenses, so depending on other expenses you might be better off taking the standard deduction. If you held the stock for less than a year you would pay the 25% income tax rate rather than capital gains. If the stock price was closer to the cost basis you would owe less for capital gains tax. If your income is low enough you might not owe any capital gains tax. If you have the cash to pay the bill, you might choose to hold onto your stock.
In general, having to pay capital gains tax is not an argument against investing in stocks any more than having to pay income tax is an argument against working. You only pay a percentage of what you make. I'd choose to keep 80% or 85% of the money I made, rather than not make any money.
EDIT: I tried to answer if deductible medical expenses could cancel out capital gains tax. Based on comments, if the question is whether to buy stocks specifically to pay for medical bills, I say no. You want to be able to choose when you sell stocks, and an illness or injury might come at a bad time to sell. I would look into a health savings account (HSA).
Bottom line up front, savings in taxes due to medical expenses can offset taxes due from capital gains.
Who argues against holding stocks? "Buy and hold" is an extremely valid investment philosophy. It's what Buffet did when he was a stock market investor. You could argue that's what he does now as a business owner. (He says that he doesn't buy stocks any more, but instead buys companies.)
You only have a capital gain if the stock has increased in value. This can be offset by selling stock which has depreciated in value. Yes it locks in the loss but it frees up the capital remaining, and offsets capital gains.
Deductions for medical expenses do not directly offset capital gains, and are limited. @Pacman's answer includes a basic treatment of the results of medical expense deduction and of capital gains taxes.
Also, if you have a HDHP, and are eligible for an HSA, selling securities from within an HSA to pay for eligible medical expenses does not trigger capital gains taxes.