You can't really avoid it. Even if you're a person with a high IQ it's just impossible to plan for every possible way that you can get hit. Experience helps a lot, but in order to gain that experience you have to be a victim.
trading requires very high patience because if you can't control the patience you have then you will often experience a lot of losses and all you have to remember is that trading has a very high risk.