Navigation: Trading Your System >

Test Output Scan

 

 

 

 

A regular Scan as defined in RealTest only has access to bar data and values calculated in the Data Section. The prior topic, Daily Setups Scan, showed how a regular scan might be used to generate a list of trading candidates for a strategy.

For situations that require access to strategy context data, such as which positions are currently open, the TestOutput Scan option provides additional capabilities.

By default, at the end of a test, RealTest "exits" all positions that remain open. These appear in the Trade List with end of test as the Exit Reason.

When a test is run with the TestOutput: Scan enabled and the script includes a TestScan section, this special scan is run automatically before the end of test exits are simulated.

This makes it possible to access all of the same position-context formula elements that are used in your strategy formulas, such as Shares, BarsHeld, FillPrice, etc.

Another use case for TestScan is to generate data throughout a test. For example, you might want to create a CSV file listing each open position on each date of a backtest. To use TestScan in this way, add TestScanAllDates: True and SaveScanAs: <file path> to your Settings.

The example script mr_sample_test_scan.rts demonstrates how to use a TestScan to produce a daily order list.

See Tomorrow's Orders for a much simpler way to do this.

The following is shows what was required in before full support for order generation was added to RealTest.

If you were using a script like this for live trading, you would simply run it in Import mode and then run it in Test mode once per day.

The TestScan section in mr_sample_test_scan.rts looks like this:

The purple names are data or library items defined earlier in the script. Here is the Library section:

These same items are used in the long and short strategy definitions, which avoids formula repetition:

Running the script with 17-Nov-2020 as the end date and TestOutput: Scan specified in the Settings section produces this output:

As you can see from the TestScan definition above, the names and contents of these columns can be whatever you want to define them as.

 

 

 

 

Copyright © 2020-2022 Systematic Solutions, LLC