Transactions that take place entirely inside the IRA are not taxable events. You can buy and sell as much as you want inside the IRA and pay no taxes.
As far as the 5-year rule, the requirement is that your withdrawal be "made after the 5-year period beginning with the first taxable year for which a contribution was made to a Roth IRA set up for your benefit" (see here). In other words, gains are not "tied" to specific investments; as long as you opened the account at least five years ago (and meet the other requirements, such as age), you can take the money out tax free.
There are separate 5-year rules for rollovers and conversions (also described on the page linked above), but these also take no account of what financial instruments your funds were invested in.
In general, transactions that take place totally within the IRA don't affect how distributions will be taxed. It doesn't matter whether you held one fund for 50 years or bought and sold every day. The IRS doesn't care what you do with the money once it's inside the IRA (except for some provisions about self-dealing and the like); they only care about when you put it in and when you take it out.