Sounds like it might be the 'shimmies' caused by your poor water quality. Fish suffering from the shimmies rock from side to side, an action known as shimmying. There are often other odd postural or behavioral traits associated with the shimmies, including clamped fins, head shaking, yawning...