It means that something is going to happen, usually bad. It is taken from the Bible:
During a feast, a prince and his guests witnessed a disembodied hand scribing the words “Mene, Mene, Tekel, Peres” on the palace wall.
The words were translated by as:
“God has numbered your kingdom and finished it; you have been judged and found wanting; your kingdom shall be divided between the Persians and the Medes.” And that, I believe is what happened.
So nowadays you might hear someone say 'he saw the writing on the wall and left before he was fired'
Or, as you say 'the writing was on the wall' which could mean that something has happened and it was clear it was going to happen beforehand.