As far as I can tell, there isn't an "isowner" comparison in mIRC. Instead of "if ($4 != $null) && ($nick isowner #) {" you could try "if ($left($nick(#,$nick).prefix,1) == ~) {" instead.
There is an isowner operator, but it doesn't work consistently across all IRCds.
Apart from that, your approach is close, but there is no .prefix property for $nick. I think you mean .pnick and then you can simply do...
if (~ isin $nick($chan,$nick).pnick)
...since the position of ~ is irrelevant due to the fact that it's an illegal nick character. Make sure ~ is the network's prefix for channel founder/owner though.
Furthermore, $nick($chan,$nick,q) may work just as well.