Well I still don't understand why you don't use /timestamp -f timestamp-format - you can change the surrounding brackets and insert colours if you want (although you'll have to re-add them in using on start since mIRC won't store the colours).

If you still want to do it with a script however, the problem isn't in the code you've given. You'll need to show an example of the code calling that alias.

As a side note that alias can be written as:
Code:
alias tstmpt {
  if (%tstmp) { return %tleft $+ $time(%tsform) $+ %tright }
}

No need for the extra $+'s