If you sell a stock at a loss and purchase the same or similar security back within 30 calendar days, you are ineligible to write off a loss against any of your other gains on that stock or any other stock.
What this does is create a complete and utter klusterfuk when doing taxes. So if you took a loss of $150,000 on a certain stock but then you bought that stock back within 30 calendar days, you are ineligible as per IRS wash sale rules, to utilize that loss against gains