BarDate and StringDate Functions
For each bar in an Optuma chart we assign a value (determined by the number of calendar days since December 31st, 1899) which can be used in scripting using the BARDATE()
function. For example, the March 6th 2008 low in the Dow Jones has a bardate value of 39,878 which is tricky to work out (you could create a custom tool tip label using just BARDATE()
as the formula to display the value when the bar is moused over).
However, it’s much easier to combine the StringDate function STRDATE()
with BARDATE()
which allows you to select the required date from a calendar popup without having to find the corresponding bardate value:
For example, to show the value of the RSI on March 23rd 2020:
D1 = BARDATE()==STRDATE(DATE=2020-03-23);
VALUEWHEN(RSI(BARS=14), D1)
Or to count the number of 52 week highs since July 1st 2019 in a Show View:
//Is it a new 52 week high?
V1 = HIGH()>HIGHESTHIGH(BACKTYPE=Weeks, BARS=52);
//Is the bardate greater than July 1st 2019?
D1 = BARDATE()>STRDATE(DATE=2019-07-01);
//Count all signals when both V1 and D1 are true
ACC(V1 and D1)
Using BARDATE in a Watchlist
Dates of specific technical events can be displayed in a watchlist column. For example, to display the date of the highest all time high use the following:
SIG1 = HIGH() == HIGHESTHIGH(RANGE=All Time);<br></br>BARDATE(SIG1)
Note
By default the column will display the bardate value (eg 43677) so right-click on the column heading and change the Column Type to Date to display in your default Windows date format:
Intraday BarDate Values
BarDates for daily, weekly, monthly charts have whole numbers, but for intraday bars they have a decimal value.This is calculated by dividing the number of minutes of the timestamp of the bar by 1,440 (ie the total number of minutes in 24 hours).
For example, 12 noon would be 12 x 60 = 720/1440 = 0.5, so the noon bar for November 1st 2022 has a BarDate value of 44,866.5: