An alternative suggestion
Code:
on me:*:connect:{
if ($me != $mnick) {
ns ghost $mnick my-pass
}
}
;this next section will vary depending on the specific notice given when you ghost your nick, so I've left it as general as I could
on *:notice:$+(*,ghost*,$mnick,*):*:{
if $nick == NickServe {
 .nick $mnick 
}
.timer 1 1 .join #my-chan
}
on me:*:nick:{
.ns identify <password>
}
 


Checks to see if your current nick is your main nick, and if it isn't sends the ghost command.
Upon reception of the notice from Nickserv that your main nick has been ghosted (you may need to change that to match the format of the notice from your nickserv), your nick is changed to your main nick and a 1 second timer is started before you join your channel.
When your nick is changed, a message identifying the nick is sent to nickserv.

I realize this is more complex than what you had, but guarantees that you don't try to send information to nickserv before the information is valid.