I'm disqualified from contributing to a Roth IRA. My uninformed speculation on why Roth IRA income caps and max annual contribution limits exist is that it's the sake of tax revenue.
The point of waiting e.g. 30 days is EXACTLY that it exposes you to gains/losses and you can rightly say the two actions are no longer connected.