Today
Today returns the date of a bar N trading days before the current one as a YYYYMMDD integer. Today[0] gives the current day's date in ProBuilder scripts.
Syntax
Today
Today[N]Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| N | integer | 0 | Number of trading periods before the current bar. 0 is the current day; N must be non-negative. |
How it works
Today exposes dates as compact integers in YYYYMMDD layout, so 1 March 2024 becomes 20240301. Without an index, or with Today[0], the keyword returns the date of the current trading day. With a positive index it walks back through the chart history: Today[10] is the date of the bar 10 trading periods before the current one.
The index counts trading days only. Weekends and market holidays do not appear in the data, so they are skipped rather than counted, and Today[5] on a Monday typically reaches back more than five calendar days.
Because YYYYMMDD integers grow with time, they order correctly under normal comparison operators. Today >= 20240301 is a valid way to gate logic to dates on or after 1 March 2024. What the format does not support is calendar arithmetic: the difference between two YYYYMMDD values is not a number of days, so elapsed-time measurements should use Timestamp instead.
Examples
Example 1, Reading a date ten trading days back (Indicator)
// Date of the bar 10 trading days before the current one
previousDate = Today[10]
RETURN previousDateThe indicator returns the YYYYMMDD date of the bar ten trading periods earlier, skipping weekends and holidays along the way.
Example 2, Activating a strategy from a fixed date (ProBacktest)
// Ignore all signals before 1 March 2024
IF Today >= 20240301 THEN
IF close CROSSES OVER Average[20](close) THEN
BUY 1 SHARES AT MARKET
ENDIF
ENDIFThe date filter confines the backtest to bars on or after the chosen day, even when a much longer history is loaded on the chart.
Example 3, Detecting the first bar of a new day (ProScreener)
// Match instruments whose current bar starts a new calendar date
newDay = Today > Today[1]
SCREENER[newDay] ("New date")Since YYYYMMDD values increase with time, the date of the current bar exceeding the previous one isolates the first bar of each new day.
Common errors and gotchas
- Date subtraction is not day counting.
20240301 - 20240229equals72, not 1. YYYYMMDD integers are positional composites, so differences across month or year boundaries are meaningless. Durations requireTimestamp. - The index counts trading days. Non-trading days are absent from the data, so
Today[5]reaches back five bars of the daily series, not five calendar days. Around holidays the calendar distance grows further. - Indexing beyond loaded history. When N exceeds the number of bars available on the chart, the lookup has no data to read and the result is unusable. Keep N within the loaded range or guard against early bars.
- Two-digit shortcuts fail. Dates must be written in full,
20240301, never240301. Truncated literals compare against the wrong magnitude and the condition silently misbehaves.
Related instructions
Yesterday, date of the day preceding a given bar.Day, day-of-month component of the bar date.Month, month component of the bar date.Year, year component of the bar date.DayOfWeek, day of the week of the bar as a number.OpenDate, date on which the bar opened, in YYYYMMDD format.TIME, closing time of a bar in HHMMSS format.Days, number of days elapsed since 1900 for linear day arithmetic.
