NinjaScript > Language Reference > Data > Bars >

GetDayBar()

Print this Topic Previous pageReturn to chapter overviewNext page

Definition
Returns a Bar object that represents a trading day whose properties for open, high, low, close, time and volume can be accessed. This bar is a virtual bar built off of the underlying data series. In some cases, the trading day bar can be used to represent a daily bar. Since this bar is virtual, its property values are calculated based on session definitions contained in the trading day only. This does not necessarily represent the actual day. You must check for a null reference since null is returned if there is insufficient intraday data to build a trading day bar.

 

!!! This method should ONLY be used for accessing prior trading day data. To access current trading day data, use the CurrentDayOHL() method.
 

Method Return Value

See below.

 

Syntax
The properties below return double values:

Bars.GetDayBar(int tradingDaysBack).Open
Bars.GetDayBar(int tradingDaysBack).High

Bars.GetDayBar(int tradingDaysBack).Low

Bars.GetDayBar(int tradingDaysBack).Close

 
The property below returns a DateTime structure:

Bars.GetDayBar(int tradingDaysBack).Time

 

The property below returns an int value:

Bars.GetDayBar(int tradingDaysBack).Volume

 

Parameters

tradingDaysBack

Number of the trading day to get OHLCV and time information from

 

 

Examples

// Print the prior trading day's close
if (Bars.GetDayBar(1) != null)
    Print("The prior trading day's close is: " + Bars.GetDayBar(1).Close.ToString());