Pregnancy test

Had a miscarriage at 5 weeks , bleeding lasted 15th-20th, I had sex on the 21st 22nd & 28th, I ovulated on the 31st, When can I test for pregnancy?