|
The Results Section is where the columns to display in any Results Window are defined. Each item becomes one column.
Here is the default set of Results window columns and their definitions:
.png)
You are welcome to edit this file (press F9 when viewing a results window) and/or include a different set of column definitions in other test scripts. A Results section in the script being run replaces the default set entirely.
Examples of some columns that you might want to add are provided as comments in this default script (rows beginning with //).
How and when the formulas are evaluated
Every test result record contains the same set of underlying Test Statistics Arrays (the green items in the above example). Your column formulas select which stats you want to display, allow you to specify the format of the numbers, and make it possible to calculate higher-level stats however you prefer.
Results column formulas are calculated only once, at the end of a test run. When they are calculated, the context is the last date of the test. Each formula is evaluated separately for every strategy in the test as well as for the test as a whole, which is how one definition fills both the test row and its per-strategy rows.
This is why, for example, S.Number is used to display the number of periods (dates) over which a test was run. The daily stats record for the first date is 1, the second date is 2, and so on. If a test ended up with 6,894 stats records, the number of the last record — and therefore the value of S.Number when the Results formulas run — is 6,894.
Similarly, for stats where we want the total count of something for the entire test, we use the Sum function over that many periods. A stats array can also be indexed backward from the end of the test: S.Date[Periods-1] in the default script is the date of the first period counted.
Results formulas can optionally reference Trade Statistics Functions, though calculating these can be slow for tests with very high trade counts.
Items that refer to other items
Any item can refer to any item defined earlier in the same section, by name and without regard to case. In the default script Periods is defined once and then used by nearly every formula below it, and MAR is simply ROR / -MaxDD.
An item whose name begins with an underscore is calculated but not displayed. Use these for intermediate results that you do not want as columns of their own — _years, _CAR, _wins and _losses in the default script are examples.
Formatting and column headings
A format specification comment can be included in any item. If no format is specified, the item will use default number formatting. Both the short-glyph form ({$0}, {%2}, {#2}, {~}) and the named-attribute form ({format: dollar, places: 0}) are accepted, and the two forms can be mixed freely from item to item.
A quoted string in the format block overrides the column heading. The default script uses Exits: {#|"Trades"} because Trades is a reserved word and cannot be an item name, but it makes a better heading. The named form of the same thing is {name: "Trades"}. Everything that refers to a column by name — sorting, CSV headers, OptScoreCol — uses the overridden heading, not the item name.
The vertical bar
The vertical bar {|} in a Results item format specification ({line: Bars} in the named form) singles that item out for two extra uses:
•it is calculated after each day of the test and displayed in the status bar as the test is running
•it is included in the Optimization Summary written to the log at the end of an optimization run — one row per marked column giving its minimum, maximum, median, average and standard deviation across all of the tests
Because a marked item is re-evaluated on every day of every test, it is worth keeping the number of them small.
Where else these columns are used
•They are the sortable headings of the Results Window and the fields written to results CSV output by ResultsFile.
•OptScoreCol names the one Results column used to rank an optimization. It must match a displayed column, so an underscore item cannot be used as the score.
•Any displayed column can be chosen as the metric plotted in Optimization Results Graphs, including the parameter sensitivity histogram.
One exception to "edit and re-apply": tests saved with OptNoStats keep no stats arrays, only the column values as they stood when the test was saved. Reopening such results matches the saved values to the current section by column name, so a renamed or newly added column shows as blank rather than being recalculated.
To apply Results section formulas to all currently open Results windows, press F4 or click Apply.
See also Default Scripts and Output Format Specification.
|