2003 Mini Cooper S

When my car sits at idle for more than a couple minutes the check engine light and DSC light comes on and the car then starts idling rough. When I check the check engine light it says misfire in cylinder 4 but after turning the car off and back on the DSC light is off and it idles fine as long as im in motion and not sitting at idle for more than a couple minutes. What could be causing this? I have changed the plugs, wires, coil pack and valve cover gasket but it still does it.