Yesterday
Yesterday returns the date of the day before a bar, in YYYYMMDD form. Yesterday accepts a bracket offset such as Yesterday[5] to reference an earlier bar.
Syntax
Yesterday[N]How it works
Yesterday returns the calendar date of the day before the bar being referenced, packed as a YYYYMMDD integer. A value of 20260707 stands for 7 July 2026. It reads the date attached to a bar and steps back one trading day, skipping non-trading days such as weekends and holidays according to the dataset.
The optional index N selects a bar relative to the one being processed. Yesterday[1] gives the date of the day just before the current bar. A larger N looks further back: Yesterday[5] gives the day before the bar five positions earlier. The chart must hold enough history for the requested offset, otherwise the value is undefined at the left edge.
Yesterday retrieves date information only. It does not read or manipulate price. For the date of a bar itself use Today, and for a single monotonic day count use Days. Because the result is a packed YYYYMMDD integer, two such values can be compared directly to test whether one date precedes another.
Examples
Example 1, Previous trading date (Indicator)
// Date of the day before the bar five periods back
dateFiveDaysAgo = Yesterday[5]
RETURN dateFiveDaysAgoThe indicator plots the YYYYMMDD date of the trading day preceding the bar five positions back, a stepped line that advances one trading day at a time.
Example 2, Scan against a reference date (ProScreener)
// Match instruments whose prior trading day is on or after a chosen date
priorDay = Yesterday[1]
SCREENER[priorDay >= 20260101 AND close > Average[20](close)] (priorDay AS "PrevDate")The screener returns instruments whose previous trading day falls in 2026 or later, with that date shown alongside, using the packed YYYYMMDD form for a direct comparison.
Example 3, New-session detection (ProOrder)
// Act on the first bar of a session, when the prior day differs from two bars back
DEFPARAM CumulateOrders = false
sessionStart = Yesterday[0] <> Yesterday[1]
IF sessionStart AND close CROSSES OVER Average[20](close) THEN
BUY 1 CONTRACT AT MARKET
ENDIFWhen the "day before" reference shifts between consecutive bars, a new trading day has begun. The strategy uses that to gate entries to the opening of a session.
Common errors and gotchas
- Packed YYYYMMDD, not a day count. Yesterday returns a date such as 20260707, not a number of days. For a running day count use
Days. - Trading days, not calendar days. The step back skips weekends and holidays per the dataset, so "yesterday" may be several calendar days earlier across a weekend.
- Date only, no price. Yesterday never touches market data; it returns a date. Pair it with a price series when building conditions.
- Offset beyond history.
Yesterday[N]needsNbars of history. Near the left edge of the chart the value is undefined.
Related instructions
Today, date of the current bar in YYYYMMDD form.Day, day of the month of each bar, 1 to 31.DayOfWeek, weekday of each bar, 1 for Monday to 7 for Sunday.Days, whole days elapsed since 1 January 1900 up to each bar.Month, month of each bar.Year, four-digit year of each bar.Timestamp, UNIX time of the close of each bar.TIME, closing time of each bar as an HHMMSS integer.
