Category
General-Purpose Functions
Description
Number of bars since (or until) a specific date
Syntax
DateBars(date)
Parameters
date - a numeric date
Notes
This function can be used to return a bar count or offset from the current bar to a specific date in the past or future.
The date parameter can be any formula returning a numeric date value.
The Date function is a convenient way to generate a numeric date.
If there is no bar with the specified date, the first bar with a date more recent than the specified date is used.
Examples
ROC(C, DateBars(Date(2016,2,1)) + 1) returns the percent gain or loss since February 1, 2016.
(The +1 is needed to make the bar count inclusive of the specified bar when using the count as a length argument.)
C[DateBars(Date(Year,1,1))] returns the closing price for the first trading date of the current year.
(Here the bar count is an offset rather than a length so the +1 is not needed.)
|