Navigation: Realtest Script Language > Script Sections > Strategy Section >

Special Strategy Types





There are two alternative ways to define a Strategy -- as a Benchmark or as a Template. All three of these strategy types are defined the same way and support all the same elements. The only difference is in which keyword is used to declare them. For an example of a script that uses all three types, see mr_sample_benchmark.rts.

A Benchmark strategy is run and its stats are calculated exactly as if it was a regular strategy. It has its own set of stats and will appear among the strategies shown in stats graphs. The only difference is that the stats of a benchmark are not included in the combined results. One use of a benchmark strategy is to plot a simple buy-and-hold equity line for visual comparison with your own strategy. A more advanced usage would be to define a basic version of a strategy which the actual strategy can refer to.

Template strategies serve to prevent the need to copy and paste elements that are common to several strategies in a script. Template strategies are not "run" in a backtest. In older versions of RealTest, there was a single template strategy called "Defaults". This has now been replaced with support for multiple named templates.

To define a template strategy, simply declare it as, for example, "Template: base". To include the elements from that template in another strategy (or template or benchmark), add the statement "Using: base" to the strategy. To include more than one template, list them separated by commas, as in "Using: base1, base2, base3".

When a strategy uses a template, it inherits all the elements defined in that template (and any others that the template uses).  It can then optionally replace some of those elements by declaring them within the strategy.

In addition to the above, StatsGroup is also a strategy-like script element.  Like these others, StatsGroup defines an outer-level section. However, the only Strategy elements that StatsGroup is allowed to contain are: Using, Allocation, MaxEntries, MaxExposure, MaxInvestement, MaxPositions, MaxSameCat, and MaxSetups.

The original purpose of StatsGroup was to define a combined statistics series, similar to Combined (which is automatically added to any test with more than one Strategy) but with a smaller subset of strategies involved in the combination.

For example, say you had two long and two short strategies in a system, called long1, long2, short1 and short2. By default your stats would include 5 series (5 lines on the Equity graph etc.): long1, long2, short1, short2, and Combined.

If you also wanted to see combined stats for both long strategies and both short strategies, you could simply add these statements to the script:

This defines two new stats series, Longs and Shorts, calculated by combining trades from both strategies of the group into its stats.

In addition to using StatsGroup to add more stats series to your test output, you can also reference them from your strategy logic. Just as the ongoing stats of any Strategy or Benchmark can be accessed using Extern(@strategyName,, all of the StatsGroup series that you define can similarly be accessed using Extern.

The default Allocation for a StatsGroup is Combined(S.Equity). Allocation is only relevant in this context because of its use in the calculation of percent-based results statistics such as S.TWEQ, S.MaxDDPct and S.NetPct. Only override the default Allocation if you need these percentages to be calculated differently.

With the addition of top-down mode in RealTest 2.0.26, the StatsGroup and Combined functionality was expanded. In this new mode a StatsGroup can include any of the Max... items listed above.

An additional section called Combined can optionally be added explicitly. If present, it also supports all of the Max... items that StatsGroup does. Note that Combined as a strategy-like section is the only such section that cannot be named, and it also may not contain Using or Allocation definitions.

When Max... constraints are specified for a StatsGroup or Combined, they are applied to all strategies in that group together.

For example, if MaxExposure: 100 is defined for Combined: then a setup in any strategy will be skipped if adding that position would push the combined exposure above 100%.

Similarly, these constraints in a StatsGroup ensure that setups will be skipped if entering those positions would exceed any them.

See Also: Backtest Engine Details and Capacity Constraints





Copyright © 2020-2024 Systematic Solutions, LLC