Navigation: Backtest Engine Details >

Bar Sizes and Multiple Timeframes




RealTest provides full support for multiple bar sizes within the same data and testing context.

When bar data is imported, daily bars are required. Intraday bar sizes will very likely be supported in the future but are not currently. Importing of higher timeframe bars is also not currently support.

However, when daily bar data is imported, weekly and monthly bars are automatically built and any of these three bar sizes is available to use in your scripts.

There is a global bar size setting that is specified either on the Settings Panel or in the TestSettings or ScanSettings script sections. Until changed, this is the default bar size that will be used in all formula elements that reference bar data.

As a simple example, the expression C > MA(C,20) will compare the daily close to the 20-day average close when BarSize is Daily, the weekly close to the 20-week average close when BarSize is Weekly, or the monthly close to the 20-month average close when BarSize is Monthly.

In addition to the global BarSize setting, there is a strategy-level BarSize setting as well. This is used when you want to combine strategies that use different bar sizes. The strategy-level setting overrides the global setting for all formulas defined within that strategy (including any Library formulas they reference, since these are context-dependent, unlike data items).

Regardless of the current global or strategy-level bar size, any part of any expression can explicitly specify a different bar size by using the Extern function with the special tilde (~) symbol. For example, Extern(~Weekly, MA(C,20)) would return a 20-week moving average of close, starting with the most recently completed week and going back 20 weeks from there, regardless of the current bar size setting.

The Data Section has both unique capabilities and unique constraints with regard to bar size, which are described here.

For an example of a script that makes full use of multiple bar sizes, see combined_multi_bar_size.rts in the Examples folder.




Copyright © 2020-2021 Systematic Solutions, LLC