Get your taxes done using TurboTax

You can carryback to 3 years.  So you have a carryback on your 2022 return, you can apply it to 2019, 2020 and 2021, i.e. you want to carryback max to the sum of all 3 years' gain.  Note, you need to do 1040X for 2019 first, then 2020, and 2021 last.