One quick tip to avoid nightmares and/or sleepless nights is to make sure that your head when sleeping is not facing a window, even if that direction is a good direction for you base on your Kua number. Doing so will attract a lot of yin energy which will make you sleepless or have nightmares.
However, if this is unavoidable, you just have to make sure that you close the window and cover it with a thick curtain. Blinds will not do because it still has small slits and thus yin energy will still come in. It has to be thick curtains.
Opening the windows in the morning is fine, but in the evening when you go to sleep make sure that they are close and is covered by a thick curtain.