Trading a strategy. Interpreting trade messages.

Click [Trade]. Zorro will connect to the broker and start spending your money.

A trading session can only be started when the market is open and price quotes are available for all traded assets. Otherwise you'll see an error message with the name of the unavailable asset. As soon as the session is running, Zorro simply waits through weekends and market closures. When logged in, the colored square next to the Server window will change to green. At first Zorro will download the initial price history for the LookBack period of the strategy.

If price history of some assets is not available or can not be downloaded, you'll see an error message directly at start. Check if the assets you want to trade are really provided by your broker and you entered their correct names in the asset list. When trading with an MT4 broker, price history often needs a long time to upload the first time. In that case you have to start the trading session several times until all price history is loaded correctly. Some brokers, like IB, apply a time limit to downloading price history. When you see a message like "Historical Market Data ... pacing violation", you must wait 10 minutes until you can start the session again.

Permanent issues with history download from certain brokers can be overcome by using the PRELOAD flag. In this case you can download price history from other sources before starting the session. This is especially recommended when your strategy requires .t1 data, which is slow to load and not provided by most brokers.

After downloading the prices, Zorro checks if there were any open trades from the previous session. The session status is stored in a .trd file in the Data folder. Any open trades will be resumed when they were not closed inbetween. After that, Zorro will run through the LookBack period and then execute the run function after every bar period. The tick function and the TMFs run whenever a new price quote arrives from the broker.

The free Zorro version allows to trade with only one Zorro instance. Zorro S can trade with several Zorro instances, brokers, and accounts simultaneously on the same PC. Broker connections of trading Zorro instances are synchronized. That means that any instance waits until the other instance has finished its current task. For this reason, do not perform lenghty operations - for instance, downloading large price histories - on the same PC on which other Zorros are live trading.

While trading, Zorro will detect when the .par, .c, .fac or .ml files that contain the parameters, rules, capital allocation factors, or machine learning models are updated by a re-training process. In that case they are automatically reloaded at the begin of the next bar period. It is recommended to retrain strategy parameters and rules regularly (see WFO) for taking care of market changes. This is especially required for parameter-free strategies that have been walk-forward optimized.

The Server Window displays the server date and time, and the current price of the asset selected by the [Asset] scrollbox if that asset is also used in the strategy (otherwise its price is not available). Arriving price quotes are indicated with a blinking asterisk. If the price is currently not available, for instance due to a server problem, XXXXX is displayed instead. The tiny rectangle is green when connected to the server, and red when the connection was lost. Make sure that the displayed time is the correct UTC time and that the local time on your PC is also set up correctly - Zorro can not trade properly when either time is wrong.

The left segment of the Progress Bar indicates the closed profit of the strategy since starting it, the right segment indicates the total profit or loss of all open trades (including phantom trades). When the right segment is green, your trades are in the profit zone; when the left segment is green, your account is in the profit zone. Otherwise the segment is red.

The Result Window below displays information about the account and profit situation, in the following form:

 4567  +1412  +50  !/\\' 

4567 Current equity, the sum of balance and value of all open trades of the account.
+1412 Money earned (or lost) by the strategy since the start, in account currency units.
+50 Current open trade value of the strategy, in account currency units.
!/\\' Current trades. ! is a trade with locked profit, / a winning, \ a losing, and ' a pending trade.

The Trade Status Page (see below) gives the most detailed view into the current account and trade situation.

Note that some trading restrictions apply to the free Zorro version. If you see in the Result Window that your equity has grown above the allowed limit, withdraw profit from your account.

Messages

When something happens, Zorro prints a message in the message window and records it in the .log file that can be opened with any text editor. The messages listed below are built in the software; their 'verbosity' can be set up with the Verbose variable. Additional messages can be generated by the strategy script using the printf function.

In a message, a trade position is identified like this:

[AUD/USD:CY:S1234] - Short trade (S) with AUD/USD, CY algorithm identifier, and a trade number ending with 1234. The trade number can be used to identify the trade in the broker's platform. If a trade is partially closed, the trade number of the 'remaining' trade can change.

{AUD/USD:CY:s1234} - Short phantom trade (lowercase s and winged brackets). Phantom trades are simulated, not executed.

(AUD/USD:CY:L) - Long pending trade (round parentheses). Pending trades are not yet opened and thus have no trade number.

If a message - especially a broker error, see below - is too long and outside the right window border, the content of the message window can be copied by double clicking into the window, then pasted in a text editor.

All messages are also recorded in a log file named demo.log or real.log, dependent on whether Zorro is trading with a demo or real account. Details about Zorro's log files can be found under export.

Startup messages

The following messages are generated at start:

Loading AUD/USD prices... 1000 h

Zorro downloaded 1000 hours recent price history from the broker's server and used it for the LookBack period. If an asset is not available for trading - which can happen with assets that US residents are not allowed to trade, f.i. some CFDs - an error message is issued and the asset must be excluded from the strategy.

Loading AUD/USD prices... 910+111 h

The PRELOAD flag was set and historic price data was available. Zorro read 910 hours price data from its history files and downloaded additional 111 hours price history from the broker's server. For portfolio strategies the number of downloaded hours can differ from asset to asset.

Loading AUD/USD prices... 1000 h, gap 48 h

There is a 48 hours gap between the end of the price data and the current time. This happens when the price server was not recently updated, for instance when trading is started during or just after a weekend or holiday. This gap is normally not harmful because prices don't change noticably during a weekend.

Loading AUD/USD prices... 835 h, 65 bars added

The price server could not cover the full LookBack period in time; 65 bars had to be substituted by Zorro. This can happen with some MT4 brokers. MT4 servers sometimes get the missing data after a waiting time; in that case the strategy just needs to be restarted after a minute. Added bars are normally not harmful, as missing prices are interpolated. But when a large number of bars has been added, indicators with long time periods can be less accurate at strategy start and cause reduced performance during the first time. Use the PRELOAD flag for overcoming price server limitations.

Loading AUD/USD prices... failed

The asset is available, but price data can not be downloaded. This can happen with MT4 servers that need a long time for sending assets that have not been requested before (f.i. because no chart with that asset was opened in the MT4 client). In such a case, start the strategy again after a minute - chances are that the MT4 server meanwhile got its act together.

[AUD/USD:CY:L4401] continuing

Zorro is resuming a previously closed or interrupted trading session and continues the trades that were opened in the previous session.

[AUD/USD:CY:L4401] externally closed

While Zorro was not trading, the trade was externally closed, either through a 'safety net' stop loss or manually in the broker platform.

Read Trend.par Trend.c Trend.fac

The parameters, rules, and capital allocation factors of the Trend strategy were loaded. This message is generated at start and again when the strategy was re-trained (see below).

Trade messages - normal trades

The following messages are generated when trades are entered or closed:

[AUD/USD:CY:S] Skipped - Lots/Margin 0

The trade was not entered because Lots or Margin was set to 0.

[AUD/USD:CY:S] Skipped - Margin 20, Min 45

The trade was not entered because MARGINLIMIT is set and the allocated Margin of 20 (in account currency units) was too low for buying 1 lot of the asset, which would require a margin of 45.

[AUD/USD:CY:S] Skipped - Risk 40, Min 90

The trade was not entered because the allowed Risk of 40 (in account currency units) was too low to cover the trade risk of 90 (see RISKLIMIT).

[AUD/USD:CY:S] Skipped - Total Margin 450

The trade was not entered because MARGINLIMIT is set and the account has not enough free margin to cover the Risk of the trade in a safe distance from a margin call. Either reduce the trade volume, or close open trades, or add some money to the account. You can see the current free margin in the broker platform, f.i. in the Account status of the FXCM Trading Station.

[AUD/USD:CY:S] Skipped - Total Risk 900

The trade was not entered because there's not enough balance in the account to safely cover the total risk of all open trades (see RISKLIMIT).

(AUD/USD:CY:S) Short 3@0.87400 Entry stop

A pending trade was opened, with an entry stop at 0.87400. If the price drops to the entry stop within EntryTime, 3 lots will be bought at 0.87400 plus slippage. Note that pending trades are not sent to the broker.

(AUD/USD:CY:S) Short 3@0.87600 Entry limit

A pending trade was opened, with an entry limit at 0.87600. If the price rises to the entry limit within EntryTime, 3 lots will be bought at 0.87600 plus slippage. Note that pending trades are not sent to the broker.

(AUD/USD:CY:S) Missed entry 0.87400 after 2 bars

The pending trade was not executed because the entry price was not met within the allowed time period (EntryTime). This message is not displayed in the window, but in the log file.

(AUD/USD:CY:S) Missed entry 0.87400 at cancellation

The pending trade was not executed because the entry price was not met until the next exit command. This message is not displayed in the window, but in the log file.

(AUD/USD:CY:S) Order expired after 48 hours

The trade was not executed because the order was entered just before the market was closed at a weekend or holiday, and EntryTime was not long enough to cover that period. This message is not displayed in the window, but in the log file.

(AUD/USD:CY:S) Balance limit exceeded

The trade was not executed because you're already too rich. Withdraw capital until your account balance stays below the limit for the free Zorro version.

[AUD/USD:CY:S4400] Short 1@0.87310 Risk 116 ptlsx

A short trade was entered at market. 1 lot was bought short at the price 0.87310. The risk of this trade - the maximum amount that can be lost due to a stop loss - is 116 units of the account currency. Other exit conditions are displayed with letters: "p" for a profit target, "t" for trailing, "l" for a profit lock, "s" for a fixed trailing step, and "x" for a fixed exit time. In the log file the entry time is also listed.

{AUD/USD:CY:l4500} Long 3@0.87310 Risk 200

A long phantom trade - mind the winged brackets and the lowercase l - was entered at market. 3 imaginary lots were bought at the price 0.87310.

[AUD/USD:CY:l4500] Long 3@0.87310 Pool trade

A pool trade in virtual hedging mode was entered at market in reaction to the opening or closing of phantom trades. 3 lots were bought at the price 0.87310.

[AUD/USD:CY:S4400] Cover 1@0.85934: +105 at 17:01

A short trade was closed by an exitShort call. 1 lot was covered at the price 0.85934 at 17:01 UTC. The profit was 105 account currency units.

[AUD/USD:CY:L4501] Sell % 1@0.85945: +33 at 17:01

A long trade was partially closed by an exitLong call. 1 lot was sold at the price 0.85945 at 17:01 UTC. The profit was 33. The rest of the position remains open. Some brokers change the trade ID when a trade is partially closed; in that case the displayed ID is for the remaining open position.

[AUD/USD:CY:L4401] Reverse 1@0.85945: +33 at 17:01

A long trade was closed by opening a short trade in opposite direction.

[AUD/USD:CY:S4400] Exit 1@0.85934: +105 at 17:01

A trade was closed by the trade management function. 1 lot was sold at the price 0.85934. The profit was 105.

[AUD/USD:CY:S2210] Closed 1@0.80201: +20.5 at 17:01

The trade was manually closed in the broker platform. 1 lot was sold at the price 0.80201. The profit was 20.5.

[AUD/USD:CY:L1200] Stop 1@0.78713: -49.30 at 17:25

The trade was stopped out at 17:25 UTC. 1 lot was sold at the price 0.78713. The loss was 49.30.

[AUD/USD:CY:S4400] Trail 1@0.79414 Stop 0.80012

The trade trailed its stop loss. The new stop is 0.80012. In TICKS mode and in life trading, a trade can trail many times within a bar. For not flooding the window with trail messages, only the first trailing per bar is printed, further trailing is not. Therefore the stop limit at the end of the bar be different than the displayed value.

Trade messages - options and futures

The following messages are generated when option or future contracts are entered, closed, or exercised:

[SPY:COT:LP0103] Buy 1 Put 20170118 210.0 100@1.16 at 20:00

Buy a SPY put option with expiration at January 18, 2017 and strike price 210 at a $116 premium (100 * 1.16).

[SPY:COT:SC0104] Write 1 Call 20170118 215.0 100@1.09 at 20:00

Sell short a SPY call option with expiration at January 18, 2017 and strike price 215 for a $109 premium (100 * 1.09).

[SPY::LP6633] Exercise 1 Put 212.0 100@209.84: +124$ at 19:00

Exercise a SPY put option with a strike price 212 at an underlying price of 209.84, and sell the underlying for a total win of $124.

[SPY::LC6634] Sell 1 Call 210.0 100@1.46: -22.00 at 19:00

Sell back a SPY call option at $1.46, for a total loss of $22.

[SPY::LC6634] Cover 1 Call 210.0 100@1.46: 22.00 at 19:00

Buy back a SPY call option at $1.46, for a total win of $22.

[SPY::LP5727] Expired 1 Put 207.0 100@209.50: -190$ at 19:00

A SPY put option expired out of the money at current underlying price 209.50. The $190 premium was lost.

[SPY::LC5728] Expired 1 Call 207.0 100@209.50: +112$ at 19:00

A SPY call option expired in the money at current underlying price 209.50. The underlying was sold at 2.50 price difference (209.50 - 207). The total profit, minus the premium, was $112.

Other messages

Thursday 24.1.2012 --- Profit $880 ---

If Verbose is at 2 or above, Zorro will display the previous day's profit/loss and a list of all currently open trades at the begin of every trading day, in the following format:

[AUD/USD:CY:S4400] +116$ s0.8733 c0.8729 e0.8731

The trade made 116$ profit, stop price is at 0.8733, current price is 0.8729, and entry price was 0.8731.

Weekend on 02.01.2012 23:00

It's weekend or holiday. Zorro takes a break and suspends trading until Sunday night when the Sydney stock market opens again (see also Weekend, StartWeek and EndWeek).

!ZDAS Exception - there is no tradeable price
[AUD/USD:CY:L] Can't open 1@0.82345 at 21:05:30

All messages that begin with an exclamation mark ("!") are information, errors, warnings, diagnostics, or other messages from the broker API (see Error Messages). A frequent message is about not being able to open or close a trade because no price quote is currently available or trading is temporarily suspended ("Instrument trading halted", "There is no tradeable price" etc.). This happens especially when assets are traded outside business hours. If a trade can not be closed, Zorro will attempt in regular intervals to close it again.

Trade status, chart and trade log

While trading, a HTML page named after the script and asset (f.i. MySystem_EURUSD.htm) in the Log folder displays a list with the live status of all open trades, a chart, and the current performance statistics. This document is generated when prices are available, and automatically updates once per minute. It can be displayed with any web browser. The HTML style can be changed by editing Source\status.htm and Source\zorro.css. When trading on a VPS, the HTML document can be stored in the server's public web folder (see WebFolder) for observing the current trade status via Internet on your PC or mobile phone. An instruction for setting up a VPS to display your trade status on the Internet can be found under Brokers.

The trade list can look like this (again, phantom trades in {..} winged brackets and pending trades in (..) parentheses):

Trade ID Lots Entry Time Entry Price Stop Trail Target Risk Profit Pips
[XAG/USD:LP:S0323]1020323
170
24.07. 07:5120.8519.78620.4720.27 - - - -
-82$
135$
102.4p
[US30:LP:L7369]1027369
9
10.08. 23:5116566170681638816876 - - - -
-219$
345$
495.4p
[USD/JPY:VO:L1488]1031488
17
19.08. 19:51102.90103.70102.44103.66 - - - -
-96$
95$
77.7p
[USD/JPY:VO:L1589]1031589
17
19.08. 23:51102.96103.70102.45103.72 - - - -
-96$
88$
71.9p
[USD/CHF:HU:S4997]1034997
10
27.08. 15:510.91470.91520.91680.9126 - - - -
-19$
-6$
-7.0p
[EUR/USD:CT:S5098]1035098
1
27.08. 19:511.31971.31831.3351 - - - - - - - -
-12$
1$
12.3p
[USD/CHF:LP:S5399]1035399
14
28.08. 07:510.91370.91520.91780.9095 - - - -
-51$
-20$
-17.1p
[USD/CHF:LS:S5300]1035300
20
28.08. 07:510.91370.91520.9178 - - - - - - - -
-72$
-28$
-17.1p
{USD/CAD:HU:s7873} 1027873
3
11.08. 19:51 1.0926 1.0850 1.1095 1.0757 - - - -
-36$
16$
75.9p
{XAG/USD:HP:l0586} 1030586
130
18.08. 07:51 19.591 19.786 19.244 - - - - - - - -
-94$
15$
14.7p
{XAG/USD:HP:l1791} 1031791
130
20.08. 07:51 19.449 19.786 19.027 - - - - - - - -
-87$
29$
29.1p
(XAU/USD:LP:L) - - - -
5
- - - - 12931293 - - - - - - - - - - - - - - - - - - - - - - - -
(XAU/USD:LS:L) - - - -
17
- - - - 12931293 - - - - - - - - - - - - - - - - - - - - - - - -
(XAG/USD:VO:L) - - - -
20
- - - - 19.75519.786 - - - - - - - - - - - - - - - - - - - - - - - -

Stop, Trail, and Target are the real current stop / trail / takeprofit limits of the trade (the Stop Loss that you see in the broker platform is different and not used for the stopping the trade). Risk is the maximum possible loss when negative, and the minimum profit of the trade when positive. Profit is the current profit or loss, retrieved from the broker API for real trades, or calculated (including spread, rollover, and commission) for phantom trades. Pips is the volume-neutral profit or loss in pips. Due to slippage or lack of liquidity, trades can always close with a worse result than projected under Risk and Profit.

A chart with the current price, the equity curve and additional curves is displayed in the status page. The chart is updated on every bar or every hour, whichever is least frequent. The properties of the chart, such as PlotWidth etc., can be set up in the script. If a different chart in [Test] mode is required, different chart properties can be set up with the conditions if(is(TRADEMODE)) or if(is(TESTMODE)).

When the [Result] button is clicked, a chart and a performance report is immediately created in the Log folder, and a list of all open trades with entry, current, and stop prices and current profit/loss is also printed in the message window. The message window content is stored in the log file, so any event is recorded for later evaluation.

All closed trades are separately recorded in a CSV spreadsheet (see Data Export) for further evaluation or statistics. The spreadsheet can be read back by Zorro for simulating a test with real trades generated by another platform; the Simulate script can be used for that.  !!  Take care not to keep the trade spreadsheet open in Excel or another program while Zorro is trading, or else it can not write into it.

Dependent on the broker plugin and on SET_PATCH parameters, the displayed entry or exit prices are not the open and close prices of the trade, but the market prices at trade entry or exit, which can slightly differ. While Zorro always records ask prices in the log, the entry and exit prices in the spreadsheet follow the usual notation of ask or bid prices dependent on trade type.

Manually closing trades

Normally you should refrain from tampering with the strategy, as it is (hopefully) already optimized and any manual intervention will most likely reduce the performance. Still, in some situations you might want to close individual trades, or lock an individual profit by placing a stop loss. You can do this directly in the broker platform (Metatrader4™ or FXCM Trading Station™). If supported by the broker API, Zorro will detect when a trade is manually closed, and also close it internally.

For closing all open trades in case of an emergency, click [Stop]. You'll then be asked first if you want to close all trades or not, and afterwards if you want to stop trading or not. Click first [Yes] for closing all trades, then [No] for continuing trading. All trades opened by this strategy will be closed; other open trades are not affected.

NFA compliance

US based accounts are restricted by NFA Compliance Rule 2-43(b). The rule requires that trades are served in a first-in, first-out order. You can not hedge positions or open more than one trade per asset, you can not place stop loss or profit targets, and you can not close trades. Instead of closing a position, a new position must be opened in opposite direction. You can also not trade certain assets on US FXCM accounts, such as gold and silver CFDs; and your leverage is limited, usually to below 50. You're also not allwoed to open more than 4 trades per week, dependent on your account deposit. All those restrictions are well-meant and intended to prevent US citizens from losing their money and suing their brokers (of course they do nevertheless). Zorro can step around all NFA restrictions - except for low leverage, missing assets, and limited trades - when the NFA flag is set. It must be set for all US based accounts, except when trading through MT4. It must not be set for all other accounts. If it is set wrongly, you'll get error messages like "!Error - can't close trade" on US accounts, and you'll get a massive number of open trades on non-US accounts as no trade is ever closed. So make sure that you know whether you live in the US or not. Note that the performance of trade systems can be inferior in NFA compliant mode.

Stopping and resuming a live trading system

While trading, Zorro stores the currently open trades, the status of the sliders, and component specific variables (AlgoVar) in a .trd file in the Data folder. This way trading can be stopped and resumed without losing track of open trades. The name of the file is composed from the script name plus the selected asset plus a "_d" in case of a demo account. If a trade can not be resumed - for instance when it was externally closed - an error message will be printed at restarting the trading session, and Zorro will resume the other trades. Because any new trade overwrites the .trd file, its previous content is stored in a .bak file at session start.

The content of any .trd file can be loaded with loadStatus. For looking into its open trades, you can use a short script like this:

function run()
{
  if(Bar >= 1) {
    SaveMode = SV_TRADES+SV_HTML;
    loadStatus("Data\\Z12_d.trd");
    quit();
  }
}

After a test run of this script, the open trades are printed in the HTML status page.

For updating Zorro to a new version, stop trading (but do not close the open trades), close Zorro, then install the new version into the same folder and start trading again. Please read the What's New page for checking if further actions are required.

For migrating a live trading system to a different PC or VPS, stop trading without closing the open trades, then copy the whole Zorro folder over to the new PC. Start trading on the new PC. Zorro will resume the old trades.

 !!  The .trd file can be simply copied over to the Data folder of a different Zorro installation for continuing the session from there. When stopping a trade session and starting a new session with the same script on a different broker or account, make sure to delete the .trd file so that open trades from the last session are not resumed with the new account or broker. This is especially important with an NFA account, since there is no way to automatically determine if trades were opened or closed on such an account.

Re-training

While trading, Zorro S can re-train the system for adapting it to the current market situation, and can also run a backtest over the live trading period. For details see Retraining and Retesting.

Switching / updating strategies

Zorro updates come out every couple of months, normally with improved versions of the Z strategies. When developing your own strategies, you'll also often get new ideas and improve the script so that is generates a few pips more than the previous version. For the transition of a live trading system from the old version to a new Zorro and/or strategy version, you have several options:

Errors and crash recovery

Zorro is designed to trade without human intervention. However, for keeping a program running for months and years, some special precautions are necessary.  !!  Never switch off an active trading system (not even in the interest of energy saving). Broker APIs often won't resume the session after being interrupted, and will then require a manual restart. Set the PC energy settings accordingly. Disable automatic Windows updates, as some of them reboot the PC. Screen savers won't harm.

Zorro will display an error message when the broker can not open or close a certain trade. There can be many reasons for this, such as an interruption of the connection to the broker, a server failure, lack of liquidity, or a closed market. If a trade was not opened, it is up to the script to cancel the trade or retry. If a trade can not be closed, Zorro will automatically close it again in regular intervals until the market opens or liquidity is available. If the close command repeatedly fails because the trade is unknown to the broker, Zorro will assume that it was already closed, stop the close attempts, and remove it from its internal trade list.

When the broker server goes down or the Internet breaks down, Zorro will be thrown out of the trade session. This often happens on Saturdays due to server maintenance. It is normally no reason to worry. Zorro will just log in again in repeated intervals until the problem is solved and it can resume the session. Every such login attempt prints a dot in the message window.

If the connection to the broker server is seriously broken for some reason and does not automatically establish again, click [Stop], then click [No] for not closing open trades and [No] for continuing trading. Zorro will log out, close the broker library, then open it and log in again. This solves problems with a 'hung' broker interface or library.

In case of a PC breakdown or software crash, re-start Zorro and click [Trade] again. Zorro will read its last trade state from the .trd file (see above) and continue trading at the point where it was shut down. The continued trades are displayed in the message window (f.i. [AUD/USD:CY:S4400] continuing...]. If you see an error message instead, a particular trade could not be continued - it might have hit a stop loss and been closed by the broker inbetween. For checking, open the broker's trade platform, f.i. the FXCM Trading Station, and compare the ID numbers of the open trades to the trades continued by Zorro.

If the PC is malfunctioning and you have to continue trading on a different PC, install Zorro there and then copy the *.trd file from the old to the new Zorro installation. Zorro will then resume the open trades on the new PC. Note that when you have no access rights to the Programs directory on your PC - f.i. when you logged in without administrator rights - the Data folder is located in the ProgramData directory.

See also:

bar, mode, Testing, Training

 

► latest version online