Exported File Formats

The trade log

Zorro records trading 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 trade messages are explained under Trading):

--- 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 spreadsheets

Three exported spreadsheet files - testtrades.csv, demotrades.csv, trades.csv - contain a description of every 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.
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 entry price (Bid or Ask, dependent on the trade type). Dependent on broker plugin and SET_PATCH parameters, the price is either the open price of the trade, or the market price at trade entry, which can slightly differ.
Exit Trade exit price (Bid or Ask, dependent on the trade type). Dependent on broker plugin and SET_PATCH parameters, the price is either the close price of the trade, or the market price at trade exit, which can slightly differ.
Profit Profit or loss in units of the account currency, as returned by 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), Exit (by a TMF that returned 1) or Closed (externally closed in the broker platform).

More 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.
 

Exporting P&L curves

When the LOGFILE flag is set in [Test] or [Trade] mode, the profit and loss curve is exported to a _pnl.csv file in the Log folder. If the BALANCE flag is set, the curve contains the daily balances, otherwise the daily equity. 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, and is used for calculating the Cold Blood Index in live trading.

When LOGFILE and a Curves file name is set in [Train] mode, the P&L curves of all optimize parameter steps are exported to a file with the given name. The same happens in [Test] mode when NumTotalCycles is set; the P&L curves of all cycles are then exported. The curves can be evaluated for research purposes, f.i. for a White's Reality Check. All curves are appended to the end of the file, so previous training or cycle runs from different scripts can add 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, the identifier of the curve 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);
}

See also:

Bars, file, asset parameters, assetHistory

► latest version online