Get your taxes done using TurboTax

On j1 you are indeed a nonresident for the first 2 calendar years, if you are a student for the first 5 calendar years. So assuming you are a nonstudent, you area nonresident alien for 2017 and 2018. In 2019 you would need to use the substantial presence test to determine residency. For 2017 and 2018 you would need to file form 1044NR plus form 8843, reporting only US source income, so you don't even have to report any of your investment income in Canada.

Once you are a resident alien, you have to report worldwide income, but you could use the foreign paid tax credit to offset taxes and there is also a treaty between the US and Canada. See Publication https://www.irs.gov/forms-pubs/about-publication-597

Also have a look at publication 519: https://www.irs.gov/publications/p519

Turbotax does not support form 1040NR nor 8843.

View solution in original post