Below is an illustration of how a 4-way switch diagram works.
Notice that the common wire is not included in the diagram - that's because it complicates the explanation because the power source may be coming from one of the switch boxes, or from the light box, itself, which would change how things are wired.
Notice in the diagram at the very bottom that the common wire (white) travels throughout the circuit and remains uninvolved with the switches, but connected together throughout. This is ideal, but rare because it requires specific circumstances (2 lengths of 3-wire cable, 2 lengths of 2-wire cable, and the source and load to be on opposite ends). Practically speaking, electricians sometimes do not have both 2 and 3 wire cable on hand, and the power does not always come from the convenient/simple side of the house.
If I were you, I would do the following:
- Go buy some way to label the wires like these wire labels.
- Go buy a multimeter (some are very reasonably priced like this one.
- Take out an extension cord that will reach between all switches and the light.
- Turn off the power.
- Disconnect every wire that was connected to the switches and light. If there are any wires just connected together and not connected to the switches or light, leave them connected together. Or, if there are any wires connected together and then to a light or switch, disconnect them from the light or switch, but leave them connected together.
- Use the multimeter with the extension cord to extend the reach of the multimeter by connecting the ground on the extension cord to one wire, and then go around to each other box with the other end of the extension cord and the multimeter set to read resistance (ohms), and find where that wire goes by touching one contact of the multimeter to the other end of the ground on the extension cord, and the other contact on every wire in every other box, until you find out where it goes. Label them with the same number. It starts out tedious, but as you find matches, the remaining "unknown" wires dwindle until you're left with the "line"/power in, and "load"/light.
- Draw a diagram of what wires you have, and where they're connected. For example:
- Box A has "unknown" wire, (1) wire, and (2) wire
- Box B has (1) wire, (2) wire, (3) wire, and (4) wire
- Box C has (3) wire, (4) wire, and (5) wire
- Box D has the light/load and (5) wire, and "unknown" wire
- Looking at the diagrams at the bottom, you should be able to figure out how to then wire those boxes. If not, re-post with that information, and people here should be able to help you.
Stay away counting on the colors. General residential guidelines suggest using white as common, black as hot, and red as switched, but as you can see from the diagrams, that is not always the case by necessity. And, moreover, it may not be the case out of convenience (sometimes people will use white as a carrier because they only need a 2 wire, and they generally don't make a 2 wire romex with only black and red) If they use the wrong colors, it's good practice to tape the end of the wire right before the connection with the right color, but I don't think it's code, and even if it is where you are, they might just not follow the code. Every single connection is not always inspected.
I hope that helps.