Trading a strategy

Click [Trade]. Zorro will connect to the broker and start spending your money. This happens in several steps:

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 shifted to UTC, and the current price of the asset selected with the [Asset] scrollbox if that asset is also used in the strategy (otherwise its price is not available). The update interval of the server window can be set up with TickTime. Arriving price quotes are indicated with a blinking asterisk. If the price is unavailable, XXXXX is displayed instead. "Closed" indicates that trading is currently suspended due to market hours, weekend, or holidays. "Out of sync" indicates a discrepancy of server time and PC time. The tiny rectangle at the right is green when connected to the server, and red when the connection was lost or no data was received for some time. Check if the displayed time is the correct UTC time and that the local time on your PC is also set up correctly. The server and PC need not be in the same time zone.

The left segment of the Progress Bar in live trading 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 Zorro displays prices as ask prices and profits/losses including commission, rollover, and spread, so the live values on the Zorro panel might look slightly different than the values in your trading platform for the same trades.

When something happens during a trading sessing, like the start of a new bar or opening a trade, Zorro prints a message in the message window and records it in the .log file that can be opened with any text editor. Details about Zorro's log files can be found in the Log chapter. 

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 the excess profits from your account.

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 top of the trade status page contains information about the session start, the last update, the last drawdown depth and CBI, and the last warning message that required a follow-up, such as suspicious asset parameters (054) or potentially orphaned trades (070).

The trade list can look like this (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.786- - - - - - - - - - - -
- - - -
135$
102.4p
[US30:LP:L7369]1027369
9
10.08. 23:511656617068- - - - - - - - - - - -
- - - -
345$
495.4p
[USD/JPY:VO:L1488]1031488
17
19.08. 19:51102.90103.70- - - - - - - - - - - -
- - - -
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.9147 0.91520.9168 0.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 - - - - - - - -
2$
15$
14.7p
{XAG/USD:HP:l1791} 1031791
130
20.08. 07:51 19.449 19.786 19.027 - - - - - - - -
11$
29$
29.1p
(XAU/USD:LP:L) - - - -
5
- - - - 12931293 - - - - - - - - - - - - - - - - - - - - - - - -
(XAU/USD:LS:L) - - - -
17
- - - - 12931293 - - - - - - - - - - - - - - - - - - - - - - - -
(XAG/USD:VO:L) - - - -
20
- - - - 19.75519.786 - - - - - - - - - - - - - - - - - - - - - - - -

ID is the identifier assigned by the broker API. Entry is the fill price, Price is the current price. Stop, Trail, and Target are the 'real' stop / trail / takeprofit limits set by the script (the 'safety net' Stop Loss in the broker platform has normally a different value and is not used for the stopping the trade). Pool trades have no 'real' stops, therefore nothing is shown in that column.  Risk is the maximum possible loss when negative, and the minimum possible 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. 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.

The displayed phantom lots do not necessarily sum up to the pool lots. The list can also contain phantom trades for the purpose of equity curve trading that do not contribute to the pool trades.

Below the trade list, a chart with the current price and the equity curve 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 and no specific action was assigned to that button, 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 while Zorro is trading. Excel prevents any other program from accessing that file.

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. 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. If trades cannot be closed for any reason (the market is not open or there is no connection to the broker), they stay open, and must then be manually closed.

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 have more than one position 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're also not allowed 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 NFA restrictions - except for low leverage, missing assets, and limited trades - when the NFA flag is set. It must normally be set for US based accounts, except when trading through MTR4. 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. Trades are not resumed from a special session that has no lookback period and opens trades already in the first run.

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.

If either the strategy or the .trd file format of a new Zorro version have changed substantially, the session cannot be resumed. In this case set the capital or lot size of the old session to zero, and wait until no more trades are open. Then you can start the new strategy.

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

Multiple instances

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. Trading Zorro instances are synchronized. That means that any instance waits until the other instance has finished its current task, such as sending an order or retrieving a price quote. This synchronization allows to trade even with a broker API that does not support many simultaneous connections, but it can also lead to long response times of the user interface, especially when lenghty operations - for instance, downloading large price histories - are performed on the PC on which other Zorros are live trading. For preventing synchronization, set (on your own risk) the NOLOCK flag in the script.

When trading the same script with several instances, make sure to either copy the script to different names, or run it from different Zorro installations. Otherwise the Zorro instances would write into the same status, .log, or .trd files, which can cause undesired behavior such as garbled log files or 'deadlock' situations.

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:

Live trading vs. backtest results

Be aware of all effects that can cause differences between live trading and backtest results. They are listed at the end of the Testing page.

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. Obviously you should not switch off the active trading PC - not even in the interest of energy saving. Set the PC energy settings accordingly. Disable automatic Windows updates, as some of them reboot the PC. Look here for how to automatically restart a session if a reboot still happens. 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.

If you trip over the power cable, or if the broker's server goes offline, Zorro gets temporarily disconnected from the trade session. This can regularly happen on Saturdays due to broker server maintenance. It is normally no reason to worry, since the session will continue automatically when the connection is established again. While disconnected, no prices are received, no bars are created, and Zorro cannot react on the market. If the situation persists, the colored square next to the server window will change from green to red, and the time in the server window will switch from server time to PC time. Zorro will then start re-login attempts in regular intervals, until the connection is established again. Since the prices during the interruption have been missed, there can be a sudden jump to the current price at reconnecting, which might affect indicators. Trade strategies should consider disconnections when they are programmed to react on price jumps.

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, will close and re-open the broker API library, then log in again. This solves problems with a 'hung' broker interface or API.

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.

If Zorro and a connected program, such as MTR4, crashed in the wrong moment, it is possible that further communication is locked and cannot be established again. In that case Zorro appears 'frozen'. The simplest way to resolve that is closing MTR4, closing Zorro, rebooting the PC, then starting MTR4 and Zorro again.

See also:

Bars, mode, log, testing, training, TradeMode

 

► latest version online