Zorro processes. Integration in 3rd party software.

Zorro can be used for trading, backtests, optimizations, or other computations under control from either a VC++ project, a software application, or a Zorro 'master' instance. For this purpose, a ZorroControl DLL provides functions to start, stop, and exchange information with one or several Zorro processes (up to 72). A Zorro process is a single Zorro.exe instance running a given script and returning a result. In this way Zorro scripts can be run from other trading platforms, user interfaces, or software tools. 



Your
 Application




 
Zorro
 Control







 Zorro
 EXE






 Zorro
 Script

 



 Zorro
 EXE




 
Master
 Script






 Zorro
 Processes





 Zorro
 Scripts

The following functions are available in the ZorroControl DLL and in the Zorro API. They can be called from other programs, or directly from a Zorro 'master' script:

zInit (int Num, int Size): int

Initializes the interprocess communication and determines the maximum number of processes and the size of the data area per process. Must be called first from the ZorroControl DLL and from all Zorro processes. Returns 0 when no communication channel could be established, otherwiee nonzero.

zOpen (int Id, const char* Commandline): HANDLE

Starts a single Zorro process with the given identifier and command line. Must be called from the ZorroControl DLL or the master instance. Returns the process handle, or 0 when no process could be started due to an error in the command line, no Zorro S license, no Zorro.exe in the same folder, or a failed zInit call. For starting the process with no window, use the -h command line option.

zStatus (int Id): int

Returns 1 when the process is still running, 0 otherwise. Must be called from the ZorroControl DLL or master instance. 

zClose (int Id)

Closes the Zorro process with the given Id. Id == 0 closes all Zorro processes. Must be called from the ZorroControl DLL or the master instance.

zData (int Id): void*

Returns a pointer to a memory area of the previously given Size for exchanging data and information with the Zorro process with the given Id. Every process has its own data area, but can also read or write to other processes' data areas. For the data area, a byte-aligned struct can be defined that contains the variables to be exchanged (see example). 

Parameters:

Num Total number of processes to handle, 2..72. The master instance is always process 1.
Size Size of the data area for information exchange per process, in bytes. 8 bytes per var, 4 bytes per int.
Id Process identifier number, 2..Num, or 1 for the master instance.
Commandline Command line parameters for the Zorro process. If no script name is given, the script of the master instance is used.

Returns:

Nonzero when successful, 0 otherwise.

Remarks:

Example (see also the Process.c script):

// data struct that is exchanged between 2 Zorros
typedef struct INFO { 
  var Position; 
} INFO;

INFO *Own, *Other;

void main()
{
// initialize IPC
  if(!zInit(2,sizeof(INFO))) {
    printf("Can't initialize process!"); 
    return;
  } 
// if main process, start second Zorro
  if(Core <= 1) zOpen(2,"-w 320"); // shift window to the side
// get pointers to own and other data struct
  Own = zData(Core);
  Other = zData(3-Core); // Core is 1 or 2
// define sliders 
  slider(1,1,1,100,"This",0);
  slider(2,1,1,100,"Other",0);
// permanently replicate the 'Other' slider to the other Zorro
  while(wait(1)) {
    slider(1,Own->Position);
    Other->Position = slider(2);
  }
  zClose(2);
}

See also:

Licenses, Core, command line ► latest version onlin