Your other question indicates you are located in the USA. Thus I am going to assume you will want a USA-based answer.
Generally speaking: At the end of the tax year you will sum together all the gains and losses from sales of stocks in that year. And then pay capital gains taxes on the total. However, there are both short-term: securities held for less than or equal to 1 year, and long-term: securities held for 1 year plus one day, or longer. I am going to assume all sales are long-term. Also, I'm assume you are selling USA-based securities.
- If you sell stock A for a loss of $10k in 2018. I will also assume that you held stock A for more than 1 year (long-term capital loss). Then if you sell stock B in 2018 for a gain of $10k, AND this is also a long-term capital gain, then your long-term captial income for 2018 is $0; $10k - $10k.
- You can then buy stock B one day later. However, you will probably violate the wash sale rule. This rule prevents taxpayers from selling a stock for the loss and then immediately buying it again simply to offset your loss. This is where things confusing. The wash-sale rule typically deals with a single stock: selling it for the loss, and then buying it back again one day later. If you were do this with two stocks... Again, talk to a tax accountant.
- If you buy stock B without breaking this rule, you will need to calculate it's gain or loss based on the new purchase date. In that case, you can think of this as a new investment which could go up or down.
- Your second question is a bit confusing. But as I said before, your '2018 capital gains income' is the sum total of your gains and losses for that year: separated into short-term and long-term categories.
- You cannot 'carry a capital loss without using it'.
- Example: Let's assume you sell Stock A in 2018 and have no other transactions. You would file a $10k capital loss. However, you may only reduce your total taxable income by $3k ($1500 if you file as married filing separately). Assume in 2019 you do not sell any stocks or have any other capital gains/losses. Then you again would subtract $3k (or $1500) from your income. This continues until your capital loss for 2018 is depleted. This is called 'capital loss carryover'.
- If instead in 2019 you sell stock C and gain $25k, then you would subtract $7k from that gain for a net gain of $22k, which you would pay capital gains taxes on.
- You first 'use' your capital loss carryover from previous years against any other capital gains you earn in a year. Then if you have any loss remaining you may reduce your taxable income up to $3k (or $1500).
- Example: You sell stock A in 2018 for a $10k loss. No other transactions occur. You reduce your taxable income and your taxes by $3k this year. Then in 2019 you sell stock D for a gain of $2k. You have $7k left of the capital loss carryover from 2018. You reduce your capital gains income to $0, and $5 loss remains. Then you reduce your taxable income by $3k again. Then you have $2k left of capital losses for 2020.
- This example assumes you are not married filing separately, since that amount is $1500 and not $3000.
- There is capital loss carryover worksheet in Schedule D instructions I urge you to look at.
- As for your final question: How to minimize your loss- you've lost the money already. You can minimize your tax liability. But honestly, if you want real 'tax tips', talk with an expert.
If you have short-term capital losses or gains, the situation becomes more complicated. The two are deducted against one another. Example: if you have $2k of short-term capital loss and only $1k of short term capital-gain, you have net $1k loss. This $1k of loss can be deducted against long-term capital gain. However, what may be important in your situation is: If all your short and long-term capital losses exceed your total capital gains for a given year, then you may deduct up to $3k (or $1500) from your other income.
For more information: Read the instructions for IRS 1040 Schedule D and IRS Publication 550. I've linked to the 2017 documents, and they may change year-to-year, so re-read again when you file your taxes.
PS- Don't call it 'labor income'. Call it 'wages, salaries, tips, etc.' It is in effect what you fill in on Line 7 on IRS form 1040.
EDIT: Added information about wash-sale rule.
EDIT: Added the fact that married filing separately- the amount is $1500 per tax year and not $3000. See IRS Form 1040 Schedule D, line 21.