# GetDayBar

#### Description <a href="#description_117" id="description_117"></a>

The function GetDayBar() outputs all values (open, high, low, close, time, median, typical, volume, and weighted) for a specified past or current day i.e. session. GetDayBar() is not intended to be used inside the chart. For this purpose, DayLinesAdv should be used instead. GetDayBar is mainly used as a high-performance replacement for [*PriorDayOHLC*](https://agenatrader.github.io/AgenaIndicator-documentation/indicators_oscillators/#priordayohlc).

Several data feed providers also offer historical data, in which case we recommend that you use GetDayBar. If it is intraday data that is offered, it still works adequately to use [*PriorDayOHLC*](https://agenatrader.github.io/AgenaIndicator-documentation/indicators_oscillators/#priordayohlc).

If the outputted data varies, the main cause is normally assumed to be the difference between Session Begin and Session End.

#### Parameters <a href="#parameters_100" id="parameters_100"></a>

daysAgo Number of days in the past (0 for the current value)

#### Return value <a href="#return-value_108" id="return-value_108"></a>

DateTime for time double for all other values

For **daysAgo = 0,** the following applies: Close = current price (for CalculateOnClosedBar = false) Time = time of the current day’s open All other values are calculated using intraday data.

#### Usage <a href="#usage_110" id="usage_110"></a>

```csharp
GetDayBar (int daysAgo)
```

#### Example <a href="#example_104" id="example_104"></a>

```csharp
[TimeFrameRequirements("1 day")]
public class xy : UserIndicator
{
  int daysAgo = 5;
  double historicalClose = Instrument.Round2TickSize(GetDayBar(daysAgo).Close);
}

protected override void OnStart()
{
  Print("The closing price from " + daysAgo + " days ago was at " + historicalClose);
}
```

**Important:** The attribute *TimeFrameRequirements* must also always be used for the class doing the calling up (in the above example, class xy) if the indicator uses *Multibars*.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://indicators.agenatrader.com/standard-indicators/getdaybar.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
