Spotting during second trimester

SR

I had medium spotting last night at 19+ weeks. The doctor checked and saw the baby was okay but advised me to take bed rest for some time. Is it ok to have sex or should I stop that as well, if so for how long?