Comment on page
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.
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)
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)
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.