Series Indexing

Top  Previous  Next

Series can be Auto Indexed or not. If the series is auto indexed according the test or instrument's current bar just like test or instrument properties. This means that when accessing the series variable the value in the [] is a lookback. Auto-Indexed series also automatically have their size set according to the number of bars of instrument data or number of days in the test depending whether they are instrument or block variables.

 

Example of an Auto-Indexed series:

 

Day 1:

customIndicator = 10        ' Sets the value of 10 for the series

                           ' at day 1.

 

Day 2:

customIndicator = 20        ' Sets the value of 20 for the series

                           ' at day 2.

 

Day 3:

Print customIndicator[1]    ' Will print the number 20 since that

                           ' is the value from one day back.

 

Note that the Block Permanent Series will Auto Index on the test's CurrentDay value, while the Instrument Permanent Series will Auto Index on the instrument's bar value. This difference is because some markets/instruments don't trade on certain days because of exchange-specific holidays.

 

Example of  accessing a series that is not Auto-Indexed (regular array):

 

If you do not select Auto-Index then each element is accessed the same regardless of the movement in through time. You need to set each value using the [] and retrieve them using the same index. You also need to set the size yourself since Trading Blox won't know how many elements you want to store in the series.

 

Errors will be generated when the non auto indexed array is used without an index [] or when the index is less than 1 or greater than the number of defined elements.

 

In the following example, customArray is a non auto-indexed array of size 10.

 

Day 1:

customArray[1] = 10                ' Sets the value of 10 into the

                             ' series at index 1

 

Day 2

customArray[3] = 20                ' Sets the value of 20 into the

                             ' series at index 3

 

Day 3

Print customArray[1]                ' Will print the value 10, since

                             ' that is the value at index 1