Get rid of the Roth IRA income cap and raise the max annual contribution limit 4x. Not that hard.
Calculate SS tax after these deductions, not before.
EDIT: Please let me know why these might be bad ideas. I think it's unfair that currently only people with employer-sponsored 401k plans can save $18k and everyone else has only an IRA with $5.5k limit. Or some people can do a self-employed 401k which is a thing I don't know a lot about. It's crazy there are so many options for what should be a simple thing "I want to put aside some money now, some of it tax free, for when I retire."
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.