Woried

I'am 17 weeks pregnant and i'm always having orgasm by masturbating , does that thing can affect my pregnancy? Or the baby? The doctor told me and my bf not to have intercourse.