A wash sale occurs when you sell or trade stock or securities at a loss and within 30 days of the sale (either before or after), you purchase the same—or a "substantially identical"—investment.
The wash-sale rule is a regulation established by the Internal Revenue Service (IRS) in order to prevent taxpayers from being able to claim artificial losses in order to maximize their tax benefits.
As opposed to maximizing tax benefits, most of us traders lost monies and committed wash sales (not able to claim tax for loss) without knowing it.
You have to wait 30 days after you sell a stock to rebuy it if you want to use it as a tax loss. I have been doing this 12 years now (trading professionally).