At this point you should really get the Query from ESPQuery.Get(QuerySetID, QueryID) rather than passing the query as a param (the open in new window issue).