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

Bar-Size-Specific Items





RealTest supports multiple bar sizes and makes it easy to mix them with correct date alignment.

Each script has a BarSize setting and can optionally specify a Strategy bar size that is different from the Settings bar size.

Each item defined in the Data Section is, by default, calculated and stored using the Settings bar size.

Data item arrays are independent of any strategy, therefore strategy bar sizes are not considered when calculating them.

If the settings bar size is Daily and the script includes a Weekly strategy, the data items used by that strategy must be explicitly written as weekly calculations.

There are two ways to make the bar size of a data item be different from the settings bar size:

1. Prefix the item name with a bar size name:

2. Use Extern:

Both of the above will calculate the average of the past 20 weekly closing prices. The difference is in how these calculated values are stored.

In the first example, one value per week is stored in the data item's memory array.

In the second example, one value per day is stored (a new value each Friday which is repeated until the following Friday).

References to either of the above from other formulas will always return the same value.

This difference in how these items are stored can be seen by enabling this item in View / Program Options:

Here is the output after calculating both items above for SPY from the start of 2015 through July 2023:

The Extern method is preferable when calculating weekly or monthly data items for reference by a daily barsize strategy. Although more memory will be consumed for each such item, references to those items will be far faster. Each lookup of a non-daily Data item value corresponding to a daily bar takes time. Storing redundant daily copies of each non-daily bar value eliminates the need for those lookups.

The name prefix method is preferable when calculating weekly or monthly data items for reference in a strategy of that same barsize. In that case the opposite applies. It uses less memory and is more efficient to store those arrays in their own bar sizes when that's how they'll be referenced.

In summary, chose the other-barsize Data item style to match the context from which it will be referenced.





Copyright © 2020-2024 Systematic Solutions, LLC