If you sell shares of a stock you own, there is no rule preventing you staying invested and rebuying shares of the same stock. The time period you should wait to repurchase the stock is dependent on the reason you sold the shares in the first place.
If you initially sold the shares to take a loss on the stock for tax purposes, take care on the timing of the repurchase. Losses from sold stock shares can be used to reduce your income taxes from other investments or income. The tax rules do not allow an investor to sell shares to take a loss and then immediately buy back the shares. This tactic is called a wash sale and the loss will be disallowed if the investor tries to claim the loss for tax purposes.
Avoiding a Wash Sale
To avoid having the loss from a stock sale disallowed due to the wash-sale rule, do not buy shares of the same stock in the period 30 days after and before the sale date of the stock. To sell a stock for a loss and take the loss as a tax deduction, an investor must wait at least the 30 days before buying the shares again. The part of the rule that disallows buying the stock 30 days before selling prevents an investor from trying to trick the Internal Revenue Service by buying the shares before selling the held shares for a tax loss.
The IRS knows all the tricks to get around the wash-sale rule and has issued regulations prohibiting these ways to purchase the shares in a different manner. You cannot rebuy the shares in another account, such as an IRA, or in the name of another family member. You cannot buy options on the stock to participate in any gains. The wash-sale rules prohibit buying shares that would be "substantially identical" to the sold shares. For example, if the stock has two classes of shares, buying the class B shares cannot be done to replace the class A shares.
Triggering a Wash Sale
If you forget about the wash-sale rule and buy back the shares within 30 days, you do not lose the tax loss, it is just postponed until you sell the newly purchased shares. The loss from the first sale of shares is added to the basis of the new shares, reducing any taxable gains in the future or increasing the loss if the shares continue to decline. The wash sale does not apply to stock shares sold for a profit. If you made a gain when you sold, you must declare and pay taxes on the stock. Outside of the limits placed on rebuying shares in the tax rules, you can buy the shares back at any time.