Every act which is useful for people is allowed and every act which is harmful is not allowed. Allah says in Quran يُحِلُّ لَهُم الطَيّبات وَيُحَرِّمُ عليهم الخبائث which means that the religion of Islam allows every good and does not allow every bad.
Writing is no exception. Writing can be useful to provide useful information and encourage good values and good deeds, and can be otherwise. Writing fictional horror stories or novels of fear and violence should be judged by the amount of harm or benefit of it to the human society. If it is harmful, then it must be avoided.
Wassalam.