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.
For example, if the settings bar size is Daily and the script includes a Weekly strategy, the Data items used by that strategy must be explicitly specified as weekly bar arrays.
To begin a group of data items with a specific bar size, you can add a BarSize statement within the Data Section itself.
For example, the following would calculate and store a 20-week moving average in a daily bar size script:
All items defined after a BarSize statement and before the next BarSize statement will be calculated and stored in that bar size.
Another way to designate an individual data item as having a specific bar size is to simply prefix its name with that BarSize name.
This example would also calculate and store a 20-week moving average in a daily bar size script:
Whether a BarSize statement is added to create a group of items with that bar size or a bar size name prefix is used for an individual item, such items are calculated and stored using bars of the designated size.
It is also possible to calculate a data formula using bars of a different size than it is stored with.
This example, like the one above, calculates a 20-week moving average:
Since the Settings bar size is daily, the weekly values are expanded into a daily array in memory. This takes more memory than the other approaches described above but may result in faster script run times if that item is being used by a daily bar strategy.
To see all the internal details about your Data items including their bar size and calculation speed, check this box in 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 Data BarSize or 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.
|