The Scan section is, in a way, similar to the Data section. You might think of it as a data query and reporting tool.
The items provided under Scan are similar to Data items in that each provides a formula to be calculated. Each named formula becomes a column in the scan output.
The two exceptions are the Filter formula and the Sort specification.
The filter formula is evaluated for every bar of every stock to determine whether to include that bar in the scan output. A bar is included only if the Filter formula evaluates to "TRUE" or a non-zero value.
The sort specification lets you name the column(s) to use for initial sorting of the rows of the scan after it is generated.
Scans can be useful during research to find specific examples of a setup for further study, or in a production system to produce the candidate list for daily trading.
See Tutorial 3 for a simple example of how to run a scan.
Here are the data and scan definitions from that example:
Notice how the scan items are able to refer to the data items, and that it's fine to give a scan column the same name as a data item.
If a Scan item name begins with an underscore, that item will not be shown in the scan output. Rather, it will just serve as an intermediate variable that other items can refer to.
As with Results, Graphs, and Charts, Scan column formulas may include a format specification comment within their formulas.
Scans can be run for any date or a range of dates. The output is a new scan window.
The data file and date range to use when running a scan can be specified by adding a ScanSettings section to the script. If no settings are specified, the settings currently shown on the Settings Panel will be used.
See Multi-Row Scan for information on how to output more than one row for each symbol+date.
The TestScan section works the same as Scan except for these details:
•TestScan must be defined in a script that also includes at least one Strategy or Benchmark section
•Formulas within a TestScan definition may refer to any syntax element that a Strategy formula can refer to
•TestScan is run by checking Scan in the Test Output area of the Settings Panel or adding TestOutput: Scan to the Settings section of the script
•The date range of a TestScan is always confined to the one last bar of the test that was just run
•Other settings for a TestScan, such as ScanSaveAs, are defined in TestSettings rather than ScanSettings
The main purpose of a TestScan vs. a general-purpose Scan is to generate customized order lists. The feature was added to RealTest for this purpose, before the CSV Order Baskets capability was introduced.
See Test Output Scan for more details on how TestScan works.