Retraining and retesting

Upon a mouse click, a live trading strategy is retrained for adapting its parameters to the current market situation, or retested for comparing the live results with a backtest over the same time period (Zorro S only). Retraining and retesting are executed by a second Zorro process, this way avoiding any interruption of the trading process. The newly trained parameters, rules, or machine learning models are automatically loaded by the trading system at the begin of the next bar.

Retraining

The retraining process is triggered either automatically, or by clicking the [Train] button while trading. A second Zorro instance will pop up and start a training run, while the first Zorro continues trading. In this training run the ReTrain boolean variable is nonzero. The script can then download new price data from the server, and generate a new parameter and AI rule set (see also workshop 5). After finishing the training run, the second Zorro closes. The new parameters, rules and factors are then automatically loaded by the trading instance. Example of a retraining statement in the script:

if(ReTrain) { 
  EndDate = 0;     // set the end date to the current date
  UpdateDays = -1; // reload new price data from the server
  SelectWFO = -1;  // select the last cycle for re-optimization
  reset(FACTORS);  // don't re-train factors
}

If the trading system is connected to a broker that does not provide price history (such as MT4 or IB), the recent price history can be downloaded by another Zorro instance with the Download script, and copied into the History folder of the trading system.

A trading system can be retrained even without a ReTrain statement in the script. In that case just download price history and train the system with another Zorro instance. Training produces new .c, .par, .fac, or .ml files in the Data folder. You can train on a different PC and then copy the files into the Data folder of the trading system. Zorro will detect that the files were updated, and load them automatically at the end of the current bar.

Re-training a WFO system is required in intervals corresponding to the length of a WFO test cycle, which is displayed in the performance report. The system normally needs not to be retrained more often, with one exception. If live trading results of a certain component or asset are exceptionally bad, the market could have been changed - for instance it could have got a different dominant cycle. In that case an extraordinary training run can be useful for getting the strategy back on track. On the other hand, re-training continues open trades and running functions with different parameters, which can cause a slight reduction in profit. So don't re-train too often.

The retraining process is normally started manually, but can also be performed automatically in regular intervals by setting the ReTrainDays variable accordingly.

Retesting

The retesting process is triggered by clicking the [Test] button while trading. Its purpose is verifying whether the script behaves in the simulation exactly as in live trading. For this, Zorro downloads historical data and then performs a backtest over the period since the begin of trading. The log, profits, and trades from the backtest can then be compared to the live trading session.

For retesting the trading session, a second Zorro instance will perform the actual test while the first Zorro continues trading. The start date of the trading session and the bar offset are transferred to the second instance via command line. In the test run the ReTest boolean variable is nonzero and can be used to set up test parameters in the script. After finishing the test, the second Zorro closes. The trade list testtrades.csv can then be compared to trades.csv. Example of a retesting statement in the script:

if(ReTest) { 
  StartDate = Command[0]; // get start date and bar offset from the trading Zorro via command line
  BarOffset = Command[1];
  EndDate = 0;     // set the end date to the current date
  UpdateDays = -1; // reload new price data from the server
  NumSampleCycles = 0; // no sample cycles
  SelectWFO = -1;  // use parameters from the last WFO cycle
}

Retest a system when at least about 50 trades have been entered; retests with few trades make not much sense. Make sure that the test runs with exactly the same parameters - bar offset, trade volume, etc. - as live trading. For retesting as accurate as possible, the price data should come from the same source as in live trading, and the asset list should reflect the current trading account parameters. Some differences between test and trading results are still unavoidable; they are listed below.

Remarks

See also:

bar, mode, Testing, Training, command line

 

► latest version online