Yes, eligibility for contributing to a Roth IRA is determined by your Modified Adjusted Gross Income (MAGI) which is based on your Adjusted Gross Income (AGI). Now, AGI includes the net capital gains from your transactions and MAGI adds back in things that were subtracted off (e.g.
tuition deductions, foreign earned income exclusion) in arriving at the
AGI. There is a worksheet in Publication 590 that has the details.
You are always entitled to contribute to a Traditional IRA. The MAGI
affects how much of your contribution is tax-deductible on that year's
tax return, but not your eligibility to contribute.
Both the above paragraphs assume that you have enough compensation
(wages, salary, self-employment income) to contribute to an IRA:
the contribution limit is $5500 or total compensation, whichever is
smaller. (If you earned only $2K as wages, you can contribute all
of it; not just your take-home pay which is what is left after
Social Security and Medicare taxes, Federal taxes etc have been
withheld from that $2K).
If your entire income is from capital gains and stock dividends, you
cannot contribute to any kind of IRA at all.