Exported Files

The trade log

Zorro records trades and other events in two files in the Log folder when the LOGFILE flag is set: a .log event log and a .csv trade spreadsheet. The .log file records the profit and price at every bar, and all events such as opening or closing a trade, adjusting a trailing stop, or a printf message by the script. If Verbose is at a higher level, it also records the daily state of all open trades, the daily profit or loss, and the current drawdown depth. Event logs are normal text files and can be opened with any text editor. Their content looks like this (the messages are explained under Log):

--- Monday 03.08. - daily profit +363$ ---
[GER30:EA:L7407] +684.97 / +685.0 pips
[GER30:HU:L7408] +684.97 / +685.0 pips
[UK100:EA:L7409] +580.55 / +464.4 pips
[USD/CAD:LP:S7612] +136.29 / +851.8 pips
[USD/CAD:LS:S7613] +68.15 / +851.8 pips
[AUD/USD:LP:L8412] +115.92 / +483.0 pips
[AUD/USD:MA:L1511] +42.50 / +265.6 pips
[USD/CAD:HU:S5412] +14.63 / +182.9 pips
[AUD/USD:HU:L5413] +28.05 / +175.3 pips
[GER30:EA:L7407] Trail 1@4746 Stop 4907
 
[5770: 04.08. 04:00]  6: 9289p 143/299
[GER30:EA:L7407] Trail 1@4746 Stop 4914
[AUD/USD:MA:L1511] Exit after 56 bars
[AUD/USD:MA:L1511] Exit 2@0.8406: +38.71 07:36
 
[5771: 04.08. 08:00]  6: 9773p 143/299
[GER30:EA:L7407] Trail 1@4746 Stop 4920
 
[5772: 04.08. 12:00]  6: 9773p 143/299
[GER30:EA:L7407] Trail 1@4746 Stop 4927
[USD/JPY:LP:S7308] Short 1@94.71 Risk 8
[USD/JPY:LS:S7309] Short 2@94.71 Risk 29
[USD/JPY:HU:S7310] Short 1@94.71 Risk 13

The name of the log file is the script name with appended .log extension. If the script contains no asset call or if the first printf message precedes it, the name of the selected asset from the scrollbox is added to the log file name. Optionally a number (LogNumber) can be added to the file name, for comparing log files generated with different script versions. New log files overwrite old log files of the same name. For preventing that the Log folder gets cluttered with thousands of log files, Zorro can be set up in Zorro.ini to automatically delete old files.

Trade lists

Three exported spreadsheet files - testtrades.csv, demotrades.csv, trades.csv - contain a description of every finished trade in comma separated format for import in Excel™ or other spreadsheet or database programs. They can be used for evaluating trade statistics or for the tax declaration. testtrades.csv is exported in [Test] mode when LOGFILE is set. demotrades.csv and trades.csv are exported in in [Trade] mode, dependent on whether a demo or real account was selected. The latter two are perpetual files, meaning that they are never overwritten, but their content is preserved and any new trade sent to the broker is just added at the end. So they will grow longer and longer until they are deleted manually or moved to a different folder. Depending on the Comma setting, numbers are exported with either a decimal comma or point, and separated with either a semicolon or a comma; this is because German spreadsheet programs require CSV data to be separated with semicolon. A trade spreadsheet (generated with Comma) looks like this:

Meaning of the fields:

Name Algo identifier (see algo), or the script name when no identifier is used.
Type Trade type, Long or Short. For options, also Put or Call.
Asset Traded asset.
ID Trade identifier number, also used in the broker's records.
Lots Number of lots. Multiply this with the asset's lot size (see above) to get the number of contracts.
Open Date and time when the trade was opened, in the format Day.Month.Year Hour:Minute.
Close Date and time when the trade was closed., in the format Day.Month.Year Hour:Minute.
Entry Trade fill price. If the fill price is not returned from the broker API, the ask or bid (dependent on Type) market price at trade entry. Not identical to TradePriceOpen, which is always the ask price.
Exit Trade exit price. If the exit fill price is not returned from the broker API, the ask or bid (dependent on Type) market price at trade exit. For in the money expired or exercised options, it's the executed underlying price. 0 for out of the money expired options.
Profit Profit or loss in units of the account currency, as returned from the broker API. Includes spread, commission, and slippage.
Rollover Interest received from or paid to the broker for keeping the trade open overnight, in units of the account currency.
ExitType Sold (by exitTrade), Reverse (by enterTrade), Stop (stop loss), Target (profit target), Time (ExitTime), Expired (options), Exit (by a TMF that returned 1), Cancelled (cancelTrade) or Closed (externally closed in the broker platform).

Spreadsheets

The print(TO_CSV,...) function offers an easy way to export backtest data or indicator values to a .csv spreadsheet in the Log folder. Under Tips & Tricks some more examples can be found for exporting data to .csv files or for importing data from an external text file, for instance to set up strategy parameters.
 

P&L curves

When the LOGFILE flag is set in [Test] or [Trade] mode, the daily profit and loss curve is exported at the end of the session to a _pnl.csv file in the Log folder. For this the session must have run for more than one day and at least one trade must have been opened and closed. In [Test] mode Zorro also generates a _pnl.dbl file in the Data folder that consists of a double array containing the daily balance or equity values in ascending date order. This file is used for calculating the Cold Blood Index in a subsequent live trading session. Note that the array samples the values at the end of the day, so its last value is not identical to the end profit when the simulation ended before the end of the day.

When LOGFILE and a Curves file name is set, the P&L curves generated from Ascent Optimization or from Test Cycles are exported to a file with the given name. The curves can be evaluated for research purposes, f.i. for White's Reality Check. All curves are appended to the end of the file, so any training or test cycles, even from different scripts, will add new curves to the same file. The file can be deleted or renamed for getting rid of old curves. Any curve is stored in the following format in the file:

  1. string Name, a null-terminated string containing a curve identifier in the form "Script_Asset_Algo_ParameterNumber_StepNumber". Example: "Workshop6_EUR/USD_TRND_2_10".
  2. int Size, the size of the subsequent Values array in bytes.
  3. double Values[], array containing the daily balance or equity values in ascending order. The number of elements is Size/8.

Here's a code snippet that reads all curves from a file and prints their identifiers and end values:

byte *Content = file_content("Log\\Balance.curves");
while(*Content) 
{ 
  string Name = Content;
  Content += strlen(Name)+1; // skip the name
  int *Size = Content;
  Content += 4;     // skip the size
  var *Values = Content;
  Content += *Size; // skip the balance array
  int Num = *Size/8; // number of values
  var Profit = Values[Num-1]; // end balance
  printf("\n%s: %.2f",Name,Profit);
}

Training data

Rules, parameters, factors, and machine learning models are exported to .c, .par, .fac, and .ml files in the Data folder. With the exception of factors, any WFO cycle exports a different set of files. The .c files contain the trained rules in C code, the .par and .fac are plain text files files containing the parameter values and factors separately for any component of the system. The .ml format is binary and depends on the used machine learning algorithm.

Brute Force optimization exports all parameter combinations and the resulting objectives to a *par.csv file in the Log folder. The first column contains the objective returns, the subsequent columns the parameter velues in the order of their appearance in the script. The exported spreadsheet can be evaluated by a script for generatiung heatmaps of any two parameters, or by Excel to generate a 3-d surface. Note that Excel requires re-arranging the objective column in a 2-d matrix for generating the surface.

Remarks

See also:

Bars, file, asset parameters, assetHistory

► latest version online