Welcome Siberian.

Getting detected is something we all have to put up with from time to time. A few pointers can help but, you'll have to develope and tailor them to suit your needs in any given situation. As previously mentioned, a lot of things (or variables) affect the detection equation. For example, your angle of approach, weather conditions and your approach speed
(on the surface and submerged).
Try to approach the target at anywhere from a 45° to 90° angle. Make sure your crew is at battlestations and your boat is rigged for silent running. Silent Running should automatically reduce your speed to an acceptably slow level. Rough seas make it harder for the enemy to detect you but if seas are calm, try going below the thermocline (thermal layer) and approaching from the depths.
Make sure you are at an angle (near any DD) that offers the least target for enemy sonar to bounce off of. If your broadside is facing the front of a destroyer, you're going to be in deep trouble if you don't correct it. Don't get too close too soon. Wait for the lead DD to pass and then continue your approach. I'm sure others will offer their own thoughts and, take your time. Don't get discouraged. This sim has a steep learning curve but, you
will get the hang of it. Good Luck.