Functions

Market · interval · time

11 names in this group.
Each comes with its signature and an example.

bar

The bars: count, index (0, 1, 2… as a series), last (the latest index), confirmed (the latest bar has closed; false while it is forming)

signature
const bar: { count: number; index: Series; last: number; confirmed: boolean }
example
map((i) => (i === bar.last && !bar.confirmed ? NaN : close[i]))

syminfo

The market: symbol 'BINANCEF:BTCUSDT', ticker 'BTCUSDT', exchange 'BINANCEF', market (spot, perp, stock…), currency 'USDT' / 'KRW', tick (the price step at the latest price; NaN when unknown), timezone (the market's: 'UTC' for crypto, 'Asia/Seoul' for Korean stocks). Unknown text is ''

signature
const syminfo: { symbol: string; ticker: string; exchange: string; name: string; market: 'spot' | 'perp' | 'stock' | 'index' | 'other' | 'unknown'; currency: string; base: string; tick: number; timezone: string }
example
const step = Number.isNaN(syminfo.tick) ? 0.01 : syminfo.tick

timeframe

The chart's interval: period ('60', '1D', '1W'…), minutes per bar, isIntraday (shorter than a day)…

signature
const timeframe: { period: string; minutes: number; seconds: number; isIntraday: boolean; isDaily: boolean; isWeekly: boolean; isMonthly: boolean }
example
const len = timeframe.isIntraday ? 50 : 20

date.hour

The hour (0–23) each bar opens at, in the market's zone (syminfo.timezone) unless one is given, e.g. date.hour('Asia/Seoul')

signature
hour(tz?: string): Series
example
date.hour('Asia/Seoul')

date.minute

The minute (0–59) each bar opens at

signature
minute(tz?: string): Series

date.dayofweek

Weekday: 0 Sunday … 6 Saturday (as in JavaScript, not Pine)

signature
dayofweek(tz?: string): Series

date.day

Day of the month (1–31)

signature
day(tz?: string): Series

date.month

Month (1–12)

signature
month(tz?: string): Series

date.year

Year

signature
year(tz?: string): Series

date.isNew

True on the first bar of each day ('D', default), week ('W', from Monday), month ('M') or year ('Y')

signature
isNew(period?: Period, tz?: string): Cond
example
bgcolor(date.isNew('W'), { color: color.alpha(color.gray, 0.15) })

date.session

True on bars opening inside 'HHMM-HHMM' (an earlier end runs past midnight: '2200-0200')

signature
session(spec: string, tz?: string): Cond
example
date.session('0900-1530', 'Asia/Seoul')

npm · GitHub