A (reasonably well-behaved) self-intersecting closed curve divides the plane into a number of components that can be coloured alternately black and white in a checkerboard manner. Declare a segment of the curve to go over or under a crossing depending on whether black is to the left or the right of the segment as it approaches the crossing. This produces a knot that is alternating by construction.
!enter image description here