Your sentence is correct. The understanding your classmates have about "had" is incorrect.
"Had" is past perfect. That means it's an event that was true, but is not currently true. Let's ignore the indirect speech for a moment, and convert the sentence to direct speech; that is, the command form.
Raise your hand if you have a question.
Compare this to:
Raise your hand if you had a question.
In this second sentence, the teacher is saying that if you had a question, but don't have a question now, you should raise your hand. This meaning is nonsense, and clearly not intended. The teacher says "have a question" because she wants you to raise your hand in order to ask the question that you still have.
Converting it into indirect speech, you must keep the same tense as the statement made in direct speech. Thus, "have" is correct.
Your post was changed a little for clarity. If this is your unregistered account and you would like to merge your two accounts, see this post. See Details, Please and the Contributor's Guide (Asking) for more tips on asking questions.
– Em. – 2018-11-19T02:52:20.2071It should be "She told them to raise their hands if they had a question." – Peter Shor – 2018-11-19T02:56:48.317