A rule of thumb is to have your knees over the pedal spindle (when tested with a plumb bob) when the pedal is at 3 o'clock. From there, you might want to go either way a little bit, depending on your comfort and feel: how smoothly you can pedal, your power output, etc. Another rule of thumb is that you know you are too far forward if you feel like you're going to fall on your face if it isn't for your bars. That means that you need your hands for support--do not test this sitting upright. It should take minimal effort on your core to hold yourself in position while pedaling on a trainer when you remove your hands from the bars.

Where it is on the rails really doesn't matter. To get KOPS, the position on the rails depends on your build, your cleat position, and your saddle height.