Is it legal?

is it against the rules to bring your glove over your head before you do your leg kick while in the stretch?

Rule 8.01b states that “Before assuming set position, the pitcher may elect to make any natural preliminary motion such as that known as ‘the stretch’. But if he so elects, he shall come to set position before delivering the ball to the batter.” So no, it’s not against the rules. As long as you come to the set position with both hands in front of the body and come to a complete stop of at least one second. you can raise your glove over your head beforehand as if you were going into the full windup. Then, once you have assumed the set position you can do your leg kick or any other motion. And incidentally, the one time you can go to the full windup, rather than the set position, with runners on base is when the bases are loaded. The runner on third is not going to try anything stupid. 8) 8)

As Zita pointed out, there is nothing in the OBRs about this…however, there is a specific rule within the modified rules that High School baseball uses that may have some relevance to your question:

Last year my son was warned by an experienced HS coach that when he comes set, the top of his glove cannot be higher than his chin. Since then, I have verifed from several independent sources that this bizarre rule does in fact exist within the most commonly used set of HS baseball rules.

Since it wasn’t a big deal to change his glove height at the set position, he did.

I realize the OP’s question referred to what the pitcher does with his glove just after coming set; however, umpires have been known to mix and match rules incorrectly on occasion…

Additionally, if there is a pick-off attempt made from the kind of stretch motion the OP described, I wonder if it could possibly be interpreted as a balk move by some umpires?

Normally, from the set position base runners (and umpires) are looking for first motion in the front foot of the pitcher. If the pitcher normally raises his hands over his head from the set position before a delivery, but then does that and makes a pick-off throw…I’m guessing most umpires would call that deceiving the runner.

I’m no expert on this, and would like to hear other opinions from experienced people at LTP.