So...you want to know how to detect a Trap in anime huh? I could probably guess why you want to know how too. It's because you fell for these so called anime Traps right? No need to feel embarrassed, every anime fan or Weeb has fallen for one at least once in their life. In the 3 years of my Weeb life, I have seen many anime Traps, while also discovering ways to detect one. And now, I have been able to come up with at 3 ways, although not guaranteed, to help you detect a Trap.
When you look at other people and you want to know their gender, what do you look at first? The hair. Hair is the most important way to differentiate Men and Women. Men has short hair that rarely goes past their shoulders, while Women usually have hair that goes past the shoulders. Traps, most of the time, has hair similar to women. Because of that, you can't trust the hair. "Oh, she has long hair so it's a girl." NO! You can't think like that. You have to be wary. So, if a certain anime character whose gender your not sure of has long hair, be prepared.
Chest size is another way to determine one's gender. I don't know if you know this but...boys don't have chests. Anime girls usually have big chests, so that makes it easier to detect a Trap. Of course, there are still anime girls who have a flat chest BUT they are usually Loli's so that makes it easier.
You may be thinking that the attitude I'm referring to is the Trap's. While the attitude may help you detect one, it is not reliable. The attitude I'm referring to are the other anime characters. There is always a difference in how anime girls treat anime boys and how anime boys treat anime girls. So, if you can find that difference, it will help you greatly. (NOTE: Do not confuse romance with this. I'm talking about the way people treat each other as the same and different gender)
So, those are the 3 ways I have been able to come up with to help any Weeb detect a Trap. These 3 ways may not help everyone but it helped me a lot so I can confirm that they do work in helping you detect a Trap.