Ongoing tax credit from stock investment loss
I know that we can claim $3,000 max credit from loss in stock investment each year and use the additional losses in future years, but what if I make a gain in the future?
Say in 2022, I have $10,000 loss, and I can claim $3,000.
In 2023, I realize $10,000 gain, can I deduct all the remaining loss from 2022, i.e. $7,000, to my 2023 gain at once?
Thank you