Series

A series is an array of values of the same type. Most series used on Tradery com contain floating point data values, but there are also time stamp series.

Series are a core concept of trading system development as they contain data points for various variables as they change over time, such as securities prices, volume, as well as results of applying various transformations to data, such indicators etc.

Series can be manipulated in various ways in order to extract useful information from their data and various technical or statistical indicators can be applied to them to generate derivative series. Series arithmetic can also be applied, using one of the supported operators: +, -, *, /. These operations can be performed between Series objecs,or between Series and numeric values.

Here are a few example on how to create Series variables:

Series s; // this creates an empty series
Series s( 100 ); // this creates an empty series with 100 elements, all set to 0
Series lows = lowSeries; // this creates a series variables called lows, referring to the lows of the default data
Series sma5 = lowSeries.SMA( 5 ); // this creates a series containing the Simple Moving Average values of the lows for the default data.

Arithmetic operators can be used to add, subtract, multily and divide two Series, or a Series and a constant

Series s1;
Series s2;

Series s3 = s1 + s2; // this creates a new series s3, with each element the sum of corresponding elements in s1 and s2

In order to add, subtract etc 2 series, they must be of the same size, or a runtime error will be triggered.

Constants can also be added, subtracted etc to series:

Series s1;

// initialize
Series s2 = s1 + 5; // creates a new series s2 where each element is the sum of the corresponding element in s1 + 5

Series can be involved in more complex expressions, and operator precedence rules as well as grouping using parantheses work as expected

// calculate the average between low, high and close series
Series avg = ( lowSeries() + highSeries() + closeSeries() )/3;

In general, different series used within a trading system are aligned to each other and to the data for the default symbol, which means that they contain as many data points as the available data for the default symbol, and each point represents some value corrsponding to the same time stamp as the corrsponding point in the data for the default symbol.

There are trading systems that use data from multiple symbols, and since their data may not contain the same number of points, or the points with the same indexes in the series may not correspond to the same timestamps, they must be synchronized. This will ensure that when running the bar loop, the bar index refers always to data points with the same timestamp, which ensures accurrate and meaningful calculations.


© 2006-2010 Tradery.com
info@tradery.com