Investors & landlords

What if the stock transaction loss was generated when I was I CA resident? Can the loss be carried over to next year when I was a nonresident?