# oc2()

ICE Data Services -

oc2() Series Functions

The oc2() function creates a series based on (open+close)/2 or retrieves individual (open+close)/2 values.

Syntax

oc2( [ nBarIndex ][, sym() | inv() ] )

Parameters

 Parameter: Description: Default: nBarIndex [Optional]Number of bar index of series to retrieve. n/a sym() | inv() [Optional]  Function of sym() or inv() to determine source for price values. Base sym/int

Return Value(s)

Returns a Series Object when nBarIndex is not specified.

Returns a single value when nBarIndex is specified.

Notes

Only available in versions 12.1 or later.

Code Examples

 ``function main() { //retrieve the value for the current price bar myVar = oc2``(``0``)``;`` `` //retrieve the value for the previous price bar myVar = oc2``(``-1``)``;`` `` //retrieve the current value for a specific symbol myVar = ``oc2``(``0``, ``sym("IBM")``)``;`` `` //retrieve the current value for a specific symbol/interval myVar = ``oc2``(``0``, ``sym("IBM,5")``)``;`` `` //retrieve the current value for a specific bar interval myVar = ``oc2``(``0``, ``inv(15)``)``;`` `` //create a Series Object of the (open+close)/2 prices. xSeries = ``oc2``()``;`` `` //create a Series Object of the (open+close)/2 prices for a specific symbol. xSeries = oc2``(``sym("IBM")``)``;`` `` //create a Series Object of the (open+close)/2 prices for a specific symbol/interval. xSeries = ``oc2``(``sym("IBM,5")``)``;`` `` //create a Series Object of the (open+close)/2 prices for a specific interval. xSeries = oc2``(``inv(15)``)``;}``