Can you have an STD if your STD tests were negative?

Did you just have one test for STDs? You would need to have at least two tests, three months apart to be sure. Some STDs take some time to develop.

You are not at risk from having an STD that you were tested for from the person you had sex with four years ago. Talk with your doctor and make sure you were throughly tested (some tests, like that for herpes, are not routinely performed in all STD exams). However, tests that are negative now will not later become positive unless you are exposed again.
As long as you were tested more than three months after the contact there is no need to retest. Retesting as the previous answer describes is only done when there is a chance that you may seroconvert after you were tested (seroconvert means to go from negative to positive because there is now enough of what the test looks for in your body to be detected where there wasn't enough initially). That can only happen if you were tested very close to the time you last had sex with someone who might have been infected.

You may wish to be retested if you suspect the test may have been wrong (it is called a false positive and though not common, they can happen), if you presently have symptoms or if you may have been exposed again.