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 a third strategy-like script element. Like these others, StatsGroup defines an outer-level section. However, the only Strategy elements that it's allowed to contain are Using and Allocation.
The purpose of StatsGroup is 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 in the series into its stats.
In addition to using StatsGroup to add more stats series to your test output, you can also use them in the strategy logic itself. Just as the ongoing stats of any Strategy or Benchmark can be accessed using Extern(@strategyName, S.xxx), 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.