Bar type scripts are used for building custom bar types that can be used interchangeably with native bar types throughout the platform. The custom data bars that are built by the script can either be based on tick, minute or daily bars depending on the underlying bar source. Note that when a bar type script is used by multiple symbols a single script instance is initialized for each one.


Setup


A Bar Type script can be set up anywhere a native bar type is used, including on charts, watchlists and in strategies.


Functions


Name

Description

OnInitialize(double)

This function is called when a new bar type instance is created.

OnTick(long, double, long, C_TickType)

This function is called on each new tick of the underlying symbol (see the BarBuilder functions).

OnDataBar(bool, long, long, double, double, double, double, double, double)

This function is called on each new OHLCV+OI bar of the underlying symbol (see the BarBuilder functions).

OnSessionClose()

This function is called when a trading session for the underlying symbol is closed.


Function Details


OnInitialize(double barSize)

This function is called when a new bar type instance is created.


Parameters


Type

Identifier

Description

double

barSize

The bar size of the new bar type being built


OnTick(long tickDateTime, double price, long size, C_TickType tickType)

This function is called on each new tick of the underlying symbol (see the BarBuilder functions).


Parameters


Type

Identifier

Description

long

tickDateTime

The tick date/time

double

price

The tick price

long

size

The tick size

C_TickType

tickType

The tick type (Bid, Ask, Last Trade, Not Last Trade) (View Options)


OnDataBar(bool isMissing, long startDateTime, long endDateTime, double open, double high, double low, double close, double volume, double openInterest)

This function is called on each new OHLCV+OI bar of the underlying symbol (see the BarBuilder functions).


Parameters


Type

Identifier

Description

bool

isMissing

Indicates whether the data bar is missing (true) or not (false)

long

startDateTime

The data bar start date/time

long

endDateTime

The data bar end date/time

double

open

The data bar open

double

high

The data bar high

double

low

The data bar low

double

close

The data bar close

double

volume

The data bar volume

double

openInterest

The data bar open interest


OnSessionClose()

This function is called when a trading session for the underlying symbol is closed.