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.
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.
If the outputted data varies, the main cause is normally assumed to be the difference between Session Begin and Session End.


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

Return value

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.


GetDayBar (int daysAgo)


[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.