You should probably use the alias for when you open a query.

Just add a '!' to the on open line; on *^:open:?:*:!query -n $nick
Code:
on *^:open:?:*:!query -n $nick | echo -g $nick * Logging: $iif($window($nick).logfile,$v1,Off)



The ! prefix (!query) tells mIRC to use it's inbuilt command and not your alias to perform the task.