Status flags

Zorro's current status can be checked through status flags that can be either on (active) or off (not active). The following function is used for checking a status flag:

is(int flag): int

Returns nonzero resp. true when the given flag (or any flag of the given flag combination) is set, otherwise zero resp. false. Flags can be combined with the '+' or '|' operator. For instance, is(TRAINMODE | TESTMODE) returns nonzero when either the TRAINMODE or the TESTMODE is active.

The following status flags are available:

TESTMODE

TRAINMODE

TRADEMODE

The script is running in [Test], [Train], resp. [Trade] mode.

DEMO

The demo account is selected through the [Account] scrollbox.

SPONSORED

The script is running on a Zorro S version.

CHANGED

The [Script] or [Asset] scrollboxes have been changed since the last script run, or the [Edit] button has been clicked. The sliders are then set back to their default positions.

AFFIRMED

The [Ok] button of a nonmodal message box has been clicked.
 

INITRUN

Initial run of the simulation before the price data is loaded and before the log file is opened. Can be used to initialize global and static variables. System variables that are not yet known - f.i. variables that depend on the asset and simulation period - are at 0 during the initial run.

FIRSTRUN

First run of the simulation with valid price data and system variables. Normally follows the INITRUN.

FIRSTINITRUN

First initial run of the script, in the case of multiple simulation runs due to training cycles or NumTotalCycles. While INITRUN and FIRSTRUN is set at the start of any simulation run, FIRSTINITRUN is only set at the really first run.

EXITRUN

Last run of the simulation. All trades are closed. Can be used to calculate results, aside from the evaluate or objective functions.
 

RUNNING

The script is currently running in the simulation. Script functions can also be executed outside a simulation run f.i. by clicking on [Result] or on a panel button.

TRADING

The script has entered or exited at least one position.

LOOKBACK

The script is currently in the lookback period, either at the begin of the simulation, or due to a RECALCULATE run.

NEWDAY

The current bar is the first bar of the current day.

FACTORS

The script is currently generating capital allocation factors in [Train] mode.

RULES

The script is currently generating trade rules in [Train] mode. If neither FACTORS nor RULES is set in [Train] mode, the script is generating parameters.
 

COMMAND

The Zorro instance was started through the command line.

EXE

The script is an executable (*.x).
 

PORTFOLIO

The script called the loop function.

ASSETS

The script called the asset function.

SELECTED

The current asset is the same as selected in the [Asset] scrollbox.

PLOTSTATS

The script called commands that plot a histogram rather than a price chart.
 

Some macros for often-used flags have been defined for convenience:

Train

The same as is(TRAINMODE).

Test

The same as is(TESTMODE).

ReTrain

Process for updating parameters or rules, started by clicking [Train] while live trading (Zorro S only).

ReTest

Process started by clicking [Test] while live trading, f.i. for comparing the live trading results with backtest results of the same period (Zorro S only).
 

Example:

function run()
{
  if(is(TRAINMODE)) set(SKIP3|TICKS);
  if(is(TESTMODE)) set(LOGFILE); 
  ...
}

See also:

mode

 

► latest version online