Skip to content
Nexus Prop LLC

NexuScript 1.5

Time and sessions

Bar times, the exchange and chart time zones, sessions, the trading day and countdowns.

hourThe hour of the bar's opening time.minuteThe minute of the bar's opening time.weekdayThe day of the week of the bar's opening time.dayThe day of the month of the bar's opening time.monthThe month of the bar's opening time.yearThe year of the bar's opening time.session.withinTests whether the bar opens inside a time window of the day.session.elapsedHow many minutes have passed since a time window opened.session.startsTests whether this is the first bar inside a time window.period.startsTests whether this bar starts a new session, day, week, month, quarter or year.clock.nowThe chart clock: the time on the bar being run.clock.bar_closeThe time the bar being run closes.clock.to_closeHow long is left until the bar being run closes.clock.countdownThe time left in the bar being run, written as a countdown such as 3:05.clock.trading_dayThe trading day the bar belongs to, as a number such as 20261030.clock.chart_zoneThe name of the time zone the chart displays.clock.exchange_zoneThe name of the time zone of the exchange the symbol trades on.clock.formatWrites a time as text in a pattern you choose, such as 2026-10-30 09:30.clock.wallSplits a time into its year, month, day, hour, minute, second and weekday on a zone's clock.clock.timeBuilds a time from a date and a time of day on a zone's clock.clock.offsetHow many minutes a zone's clock is ahead of UTC at a given time.session.is_openTests whether the symbol's trading session is open on the chart clock.session.open_timeWhen the current trading session opened, or when the next one opens while it is closed.session.close_timeWhen the current trading session closes, or when the next one closes while it is closed.session.to_openHow long until the next trading session opens.session.to_closeHow long is left until the current trading session closes.

hour

functionNexuScript 1.0

The hour of the bar's opening time.

Syntax

hour(zone::String = "") -> Number

Parameters

NameTypeDefaultDescription
zoneString""The time zone to read the clock in: an IANA name such as "America/New_York" or "Europe/London". Leave it out, or give "", for the exchange zone of the symbol.

Returns

Number A whole number from 0 to 23.

Units and time zones

Read from the bar's opening time. "" means the exchange zone of the symbol (symbol.timezone), or UTC when the feed gives none. Any other zone is an IANA name such as "America/New_York", and clock changes for summer time are handled for you.

Missing values

Never missing. Every bar has an opening time.

Live and historical bars

These read the bar's own opening time, so live and historical bars behave the same. A forming bar gives the same answer while it updates and after it closes.

Errors

  • NS405the zone is not a time zone name the chart knows

Example

plot("Hour", hour("America/New_York"))

See also

minutesession.withintime

minute

functionNexuScript 1.0

The minute of the bar's opening time.

Syntax

minute(zone::String = "") -> Number

Parameters

NameTypeDefaultDescription
zoneString""The time zone to read the clock in: an IANA name such as "America/New_York" or "Europe/London". Leave it out, or give "", for the exchange zone of the symbol.

Returns

Number A whole number from 0 to 59.

Units and time zones

Read from the bar's opening time. "" means the exchange zone of the symbol (symbol.timezone), or UTC when the feed gives none. Any other zone is an IANA name such as "America/New_York", and clock changes for summer time are handled for you.

Missing values

Never missing. Every bar has an opening time.

Live and historical bars

These read the bar's own opening time, so live and historical bars behave the same. A forming bar gives the same answer while it updates and after it closes.

Errors

  • NS405the zone is not a time zone name the chart knows

Example

plot("Minutes into the day", hour() * 60 + minute())

See also

hoursession.elapsedtime

weekday

functionNexuScript 1.0

The day of the week of the bar's opening time.

Syntax

weekday(zone::String = "") -> Number

Parameters

NameTypeDefaultDescription
zoneString""The time zone to read the clock in: an IANA name such as "America/New_York" or "Europe/London". Leave it out, or give "", for the exchange zone of the symbol.

Returns

Number A whole number from 1 (Monday) to 7 (Sunday).

Details

Weeks start on Monday, so Monday is 1, Friday is 5 and Sunday is 7. A futures session that opens on Sunday evening has bars with weekday 7 until midnight.

Units and time zones

Read from the bar's opening time. "" means the exchange zone of the symbol (symbol.timezone), or UTC when the feed gives none. Any other zone is an IANA name such as "America/New_York", and clock changes for summer time are handled for you.

Missing values

Never missing. Every bar has an opening time.

Live and historical bars

These read the bar's own opening time, so live and historical bars behave the same. A forming bar gives the same answer while it updates and after it closes.

Errors

  • NS405the zone is not a time zone name the chart knows

Example

if weekday("America/New_York") == 5
    background(color.fade(color.orange, 85))
end

See also

dayperiod.startstime

day

functionNexuScript 1.0

The day of the month of the bar's opening time.

Syntax

day(zone::String = "") -> Number

Parameters

NameTypeDefaultDescription
zoneString""The time zone to read the clock in: an IANA name such as "America/New_York" or "Europe/London". Leave it out, or give "", for the exchange zone of the symbol.

Returns

Number A whole number from 1 to 31.

Units and time zones

Read from the bar's opening time. "" means the exchange zone of the symbol (symbol.timezone), or UTC when the feed gives none. Any other zone is an IANA name such as "America/New_York", and clock changes for summer time are handled for you.

Missing values

Never missing. Every bar has an opening time.

Live and historical bars

These read the bar's own opening time, so live and historical bars behave the same. A forming bar gives the same answer while it updates and after it closes.

Errors

  • NS405the zone is not a time zone name the chart knows

Example

plot("Day of month", day("America/New_York"))

See also

monthweekdayyear

month

functionNexuScript 1.0

The month of the bar's opening time.

Syntax

month(zone::String = "") -> Number

Parameters

NameTypeDefaultDescription
zoneString""The time zone to read the clock in: an IANA name such as "America/New_York" or "Europe/London". Leave it out, or give "", for the exchange zone of the symbol.

Returns

Number A whole number from 1 (January) to 12 (December).

Units and time zones

Read from the bar's opening time. "" means the exchange zone of the symbol (symbol.timezone), or UTC when the feed gives none. Any other zone is an IANA name such as "America/New_York", and clock changes for summer time are handled for you.

Missing values

Never missing. Every bar has an opening time.

Live and historical bars

These read the bar's own opening time, so live and historical bars behave the same. A forming bar gives the same answer while it updates and after it closes.

Errors

  • NS405the zone is not a time zone name the chart knows

Example

plot("Month", month())

See also

dayyearperiod.starts

year

functionNexuScript 1.0

The year of the bar's opening time.

Syntax

year(zone::String = "") -> Number

Parameters

NameTypeDefaultDescription
zoneString""The time zone to read the clock in: an IANA name such as "America/New_York" or "Europe/London". Leave it out, or give "", for the exchange zone of the symbol.

Returns

Number The year in four digits, such as 2026.

Units and time zones

Read from the bar's opening time. "" means the exchange zone of the symbol (symbol.timezone), or UTC when the feed gives none. Any other zone is an IANA name such as "America/New_York", and clock changes for summer time are handled for you.

Missing values

Never missing. Every bar has an opening time.

Live and historical bars

These read the bar's own opening time, so live and historical bars behave the same. A forming bar gives the same answer while it updates and after it closes.

Errors

  • NS405the zone is not a time zone name the chart knows

Example

plot("Year", year("Etc/UTC"))

See also

monthdaytime

session.within

functionNexuScript 1.0

Tests whether the bar opens inside a time window of the day.

Syntax

session.within(window::String, zone::String = "") -> Bool

Parameters

NameTypeDefaultDescription
windowStringrequiredThe time window as "HHMM-HHMM", for example "0930-1600". The start is inside the window and the end is not. A window may cross midnight ("1800-0200"), and "1800-1800" is 24 hours from 18:00.
zoneString""The time zone to read the clock in: an IANA name such as "America/New_York" or "Europe/London". Leave it out, or give "", for the exchange zone of the symbol.

Returns

Bool true when the bar's opening time is inside the window.

Details

On daily and weekly charts it is always false, because one bar covers the whole day.

Units and time zones

Read from the bar's opening time. "" means the exchange zone of the symbol (symbol.timezone), or UTC when the feed gives none. Any other zone is an IANA name such as "America/New_York", and clock changes for summer time are handled for you. The window is read on the clock of that zone.

Missing values

Never missing. Every bar has an opening time.

Live and historical bars

These read the bar's own opening time, so live and historical bars behave the same. A forming bar gives the same answer while it updates and after it closes.

Errors

  • NS406the window is not written as "HHMM-HHMM"
  • NS405the zone is not a time zone name the chart knows

Example

if session.within("0930-1600", "America/New_York")
    background(color.fade(color.green, 90))
end

See also

session.startssession.elapsedhour

session.elapsed

functionNexuScript 1.0

How many minutes have passed since a time window opened.

Syntax

session.elapsed(window::String, zone::String = "") -> Number

Parameters

NameTypeDefaultDescription
windowStringrequiredThe time window as "HHMM-HHMM", for example "0930-1600". The start is inside the window and the end is not. A window may cross midnight ("1800-0200"), and "1800-1800" is 24 hours from 18:00.
zoneString""The time zone to read the clock in: an IANA name such as "America/New_York" or "Europe/London". Leave it out, or give "", for the exchange zone of the symbol.

Returns

Number The minutes from the start of the window to the bar's opening time. 0 on the first bar of the window.

Details

A window that crosses midnight keeps counting past midnight.

Units and time zones

Read from the bar's opening time. "" means the exchange zone of the symbol (symbol.timezone), or UTC when the feed gives none. Any other zone is an IANA name such as "America/New_York", and clock changes for summer time are handled for you. The window is read on the clock of that zone. The result is in minutes.

Missing values

Gives missing when the bar opens outside the window, and always on daily and weekly charts.

Live and historical bars

These read the bar's own opening time, so live and historical bars behave the same. A forming bar gives the same answer while it updates and after it closes.

Errors

  • NS406the window is not written as "HHMM-HHMM"
  • NS405the zone is not a time zone name the chart knows

Example

plot("Minutes since the open", session.elapsed("0930-1600", "America/New_York"))

See also

session.withinsession.startsminute

session.starts

functionNexuScript 1.0

Tests whether this is the first bar inside a time window.

Syntax

session.starts(window::String, zone::String = "") -> Bool

Parameters

NameTypeDefaultDescription
windowStringrequiredThe time window as "HHMM-HHMM", for example "0930-1600". The start is inside the window and the end is not. A window may cross midnight ("1800-0200"), and "1800-1800" is 24 hours from 18:00.
zoneString""The time zone to read the clock in: an IANA name such as "America/New_York" or "Europe/London". Leave it out, or give "", for the exchange zone of the symbol.

Returns

Bool true on the first bar inside each day's window. Also true on the oldest bar of the chart when it is inside the window.

Details

Use it to reset a value at the open, such as the opening range. On daily and weekly charts it is always false.

Units and time zones

Read from the bar's opening time. "" means the exchange zone of the symbol (symbol.timezone), or UTC when the feed gives none. Any other zone is an IANA name such as "America/New_York", and clock changes for summer time are handled for you. The window is read on the clock of that zone.

Missing values

Never missing. Every bar has an opening time.

Live and historical bars

These read the bar's own opening time, so live and historical bars behave the same. A forming bar gives the same answer while it updates and after it closes.

Errors

  • NS406the window is not written as "HHMM-HHMM"
  • NS405the zone is not a time zone name the chart knows

Example

if session.starts("0930-1600", "America/New_York")
    marker("Open", position = "below")
end

See also

session.withinperiod.startsstate

period.starts

functionNexuScript 1.0

Tests whether this bar starts a new session, day, week, month, quarter or year.

Syntax

period.starts(anchor::String) -> Bool

Parameters

NameTypeDefaultDescription
anchorStringrequiredWhich period to watch. "Session" is the symbol's trading session (from symbol.session), or the calendar day when the symbol has none. "Week" starts on Monday. One of "Session", "Day", "Week", "Month", "Quarter", "Year".

Returns

Bool true on the first bar of each new period, and on the oldest bar of the chart.

Details

These are the same boundaries the built-in VWAP and pivots use. For futures, "Session" starts at the evening open, while "Day" starts at midnight.

Units and time zones

Always read in the exchange zone of the symbol (symbol.timezone), from the bar's opening time.

Missing values

Never missing. Every bar has an opening time.

Live and historical bars

These read the bar's own opening time, so live and historical bars behave the same. A forming bar gives the same answer while it updates and after it closes.

Example

state day_high = missing
on bar
    if period.starts("Session")
        day_high = high
    else
        day_high = max(day_high, high)
    end
    plot("Session high", day_high)
end

See also

session.startssymbol.sessionweekday

clock.now

functionNexuScript 1.3

The chart clock: the time on the bar being run.

Syntax

clock.now() -> Number

Returns

Number A time. On a closed bar it is the bar's closing time; on the forming bar it is the latest time the chart gave, never before the bar opened or after it closes.

Details

It is read without brackets. Because a closed bar always reads its closing time, a script gives the same history on every run.

Units and time zones

A time in milliseconds since 1 January 1970 UTC, the same kind of number as time. A time is one instant everywhere; read its wall clock with clock.wall or clock.format. Zones: "" or "exchange" is the symbol's exchange zone (symbol.timezone, or UTC when the feed gives none); "chart" is the chart's display zone (the exchange zone when the chart does not say); "UTC" and IANA names such as "America/New_York" work too, and clock changes for summer time are handled for you. hour, minute, weekday, day, month and year accept "chart" and "exchange" as well.

Missing values

Never missing.

Live and historical bars

The chart clock never changes history. On a closed bar it is the bar's closing time. On the forming (newest, live) bar it is the time the chart gives with each price update, kept between the bar's open and close; when the chart gives no time, and always in a backtest, it is the bar's opening time. A script runs on each price update, so anything it shows from the clock refreshes with each update, not every second.

Example

plot("Seconds into the bar", (clock.now - time) / 1000)

See also

clock.bar_closeclock.to_closetimeclock.wall

clock.bar_close

functionNexuScript 1.3

The time the bar being run closes.

Syntax

clock.bar_close() -> Number

Returns

Number The bar's opening time plus the bar length (timeframe.seconds).

Units and time zones

A time in milliseconds since 1 January 1970 UTC, the same kind of number as time. A time is one instant everywhere; read its wall clock with clock.wall or clock.format. Zones: "" or "exchange" is the symbol's exchange zone (symbol.timezone, or UTC when the feed gives none); "chart" is the chart's display zone (the exchange zone when the chart does not say); "UTC" and IANA names such as "America/New_York" work too, and clock changes for summer time are handled for you. hour, minute, weekday, day, month and year accept "chart" and "exchange" as well.

Missing values

Never missing. When the chart does not say how long a bar is, one minute is used.

Live and historical bars

The chart clock never changes history. On a closed bar it is the bar's closing time. On the forming (newest, live) bar it is the time the chart gives with each price update, kept between the bar's open and close; when the chart gives no time, and always in a backtest, it is the bar's opening time. A script runs on each price update, so anything it shows from the clock refreshes with each update, not every second.

Example

if bar.last
    marker(clock.format(clock.bar_close, "HH:mm:ss", zone = "chart"))
end

See also

clock.nowclock.to_closetimetimeframe.seconds

clock.to_close

functionNexuScript 1.3

How long is left until the bar being run closes.

Syntax

clock.to_close() -> Number

Returns

Number The milliseconds from clock.now to clock.bar_close. Always 0 on closed bars.

Units and time zones

Milliseconds. Divide by 1000 for seconds or by 60000 for minutes.

Missing values

Never missing.

Live and historical bars

The chart clock never changes history. On a closed bar it is the bar's closing time. On the forming (newest, live) bar it is the time the chart gives with each price update, kept between the bar's open and close; when the chart gives no time, and always in a backtest, it is the bar's opening time. A script runs on each price update, so anything it shows from the clock refreshes with each update, not every second.

Example

plot("Left (s)", clock.to_close / 1000)

See also

clock.countdownclock.bar_closeclock.now

clock.countdown

functionNexuScript 1.3

The time left in the bar being run, written as a countdown such as 3:05.

Syntax

clock.countdown() -> String

Returns

String Text as "m:ss", or "h:mm:ss" when an hour or more is left. Closed bars read "0:00".

Details

Text cannot be plotted; show it with table, marker or print. It refreshes with each price update, not every second.

Units and time zones

Seconds are rounded up, so 0:00 shows only once the bar has closed.

Missing values

Empty text when the time left cannot be known.

Live and historical bars

The chart clock never changes history. On a closed bar it is the bar's closing time. On the forming (newest, live) bar it is the time the chart gives with each price update, kept between the bar's open and close; when the chart gives no time, and always in a backtest, it is the bar's opening time. A script runs on each price update, so anything it shows from the clock refreshes with each update, not every second.

Example

if bar.last
    table([["Bar closes in", clock.countdown]])
end

See also

clock.to_closetableclock.format

clock.trading_day

functionNexuScript 1.3

The trading day the bar belongs to, as a number such as 20261030.

Syntax

clock.trading_day() -> Number

Returns

Number A whole number written as YYYYMMDD: the day the session closes on, in the exchange zone.

Details

Keep it in a state variable to notice when it changes, or use period.starts("Session") to catch the first bar of each new day.

Units and time zones

Read from the bar's opening time, in the exchange zone of the symbol. A futures evening session belongs to the next day: a bar at 18:00 New York time on Thursday 29 October 2026 is on trading day 20261030. When the symbol has no session it is the calendar day.

Missing values

Never missing.

Live and historical bars

The chart clock never changes history. On a closed bar it is the bar's closing time. On the forming (newest, live) bar it is the time the chart gives with each price update, kept between the bar's open and close; when the chart gives no time, and always in a backtest, it is the bar's opening time. A script runs on each price update, so anything it shows from the clock refreshes with each update, not every second.

Example

plot("Trading day", clock.trading_day)

See also

period.startssymbol.sessionclock.wall

clock.chart_zone

valueNexuScript 1.3

The name of the time zone the chart displays.

Syntax

clock.chart_zone::String

Returns

String An IANA zone name as text, such as Europe/London. When the chart does not say, the exchange zone.

Units and time zones

Zones: "" or "exchange" is the symbol's exchange zone (symbol.timezone, or UTC when the feed gives none); "chart" is the chart's display zone (the exchange zone when the chart does not say); "UTC" and IANA names such as "America/New_York" work too, and clock changes for summer time are handled for you. hour, minute, weekday, day, month and year accept "chart" and "exchange" as well.

Missing values

Fixed for the whole run, so it may be read in setup. Never empty: it falls back to the exchange zone, and that to UTC.

Example

const zone = clock.chart_zone
on bar
    if bar.last
        table([["Chart zone", zone]])
    end
end

See also

clock.exchange_zoneclock.formatsymbol.timezone

clock.exchange_zone

valueNexuScript 1.3

The name of the time zone of the exchange the symbol trades on.

Syntax

clock.exchange_zone::String

Returns

String An IANA zone name as text, such as America/Chicago, or Etc/UTC when the feed gives none.

Details

Unlike symbol.timezone, it is never empty: it shows the zone the clock functions really use.

Units and time zones

Zones: "" or "exchange" is the symbol's exchange zone (symbol.timezone, or UTC when the feed gives none); "chart" is the chart's display zone (the exchange zone when the chart does not say); "UTC" and IANA names such as "America/New_York" work too, and clock changes for summer time are handled for you. hour, minute, weekday, day, month and year accept "chart" and "exchange" as well.

Missing values

Fixed for the whole run, so it may be read in setup. Never empty.

Example

if bar.last
    table([["Exchange zone", clock.exchange_zone]])
end

See also

clock.chart_zonesymbol.timezoneclock.offset

clock.format

functionNexuScript 1.3

Writes a time as text in a pattern you choose, such as 2026-10-30 09:30.

Syntax

clock.format(time::Number, pattern::String = "yyyy-MM-dd HH:mm", zone::String = "") -> String

Parameters

NameTypeDefaultDescription
timeNumberrequiredThe time to write, such as time, clock.now or clock.bar_close.
patternString"yyyy-MM-dd HH:mm"How to write it. yyyy is the year (2026), yy its last two digits, MMMM the month name (October), MMM its first three letters, MM the month with a leading zero, M without, dddd the weekday name (Friday), ddd its first three letters, dd the day with a leading zero, d without, HH the hour from 00 to 23, H without the zero, hh the hour from 01 to 12, h without the zero, mm minutes, ss seconds and a AM or PM. Any other character is kept as written.
zoneString""The time zone to read it in. "exchange" (or "", the default) is the symbol's exchange zone, "chart" is the zone the chart displays, and you may also give "UTC" or an IANA name such as "America/New_York" or "Europe/London".

Returns

String The time as text.

Details

Longer tokens are matched first, so MMMM is the month name and not two months. Month and day names are in English.

Units and time zones

A time in milliseconds since 1 January 1970 UTC, the same kind of number as time. A time is one instant everywhere; read its wall clock with clock.wall or clock.format. Zones: "" or "exchange" is the symbol's exchange zone (symbol.timezone, or UTC when the feed gives none); "chart" is the chart's display zone (the exchange zone when the chart does not say); "UTC" and IANA names such as "America/New_York" work too, and clock changes for summer time are handled for you. hour, minute, weekday, day, month and year accept "chart" and "exchange" as well.

Missing values

A missing time gives empty text.

Errors

  • NS405the zone is not "exchange", "chart", "UTC" or a time zone name the chart knows

Example

if bar.last
    table([["Bar opened", clock.format(time, "ddd d MMM, h:mm a", zone = "chart")]])
end

See also

clock.wallclock.countdownstring

clock.wall

functionNexuScript 1.3

Splits a time into its year, month, day, hour, minute, second and weekday on a zone's clock.

Syntax

clock.wall(time::Number, zone::String = "") -> (year = Number, month = Number, day = Number, hour = Number, minute = Number, second = Number, weekday = Number)

Parameters

NameTypeDefaultDescription
timeNumberrequiredThe time to split, such as time or clock.now.
zoneString""The time zone to read it in. "exchange" (or "", the default) is the symbol's exchange zone, "chart" is the zone the chart displays, and you may also give "UTC" or an IANA name such as "America/New_York" or "Europe/London".

Returns

(year = Number, month = Number, day = Number, hour = Number, minute = Number, second = Number, weekday = Number) A named tuple (year, month, day, hour, minute, second, weekday). Months run from 1 to 12 and weekdays from 1 (Monday) to 7 (Sunday). Read a part as w.hour, or unpack it with let (y, mo, d, h, mi, s, wd) = ....

Units and time zones

A time in milliseconds since 1 January 1970 UTC, the same kind of number as time. A time is one instant everywhere; read its wall clock with clock.wall or clock.format. Zones: "" or "exchange" is the symbol's exchange zone (symbol.timezone, or UTC when the feed gives none); "chart" is the chart's display zone (the exchange zone when the chart does not say); "UTC" and IANA names such as "America/New_York" work too, and clock changes for summer time are handled for you. hour, minute, weekday, day, month and year accept "chart" and "exchange" as well.

Missing values

A missing time gives a tuple where every part is missing.

Errors

  • NS405the zone is not "exchange", "chart", "UTC" or a time zone name the chart knows

Example

let w = clock.wall(clock.now, zone = "chart")
plot("Chart hour", w.hour)

See also

clock.timeclock.formathourtuple

clock.time

functionNexuScript 1.3

Builds a time from a date and a time of day on a zone's clock.

Syntax

clock.time(year::Number, month::Number, day::Number, hour::Number = 0, minute::Number = 0, second::Number = 0, zone::String = "") -> Number

Parameters

NameTypeDefaultDescription
yearNumberrequiredThe year, such as 2026.
monthNumberrequiredThe month, 1 for January to 12 for December. A month past the range rolls over: 13 is January of the next year.
dayNumberrequiredThe day of the month. A day past the end of the month rolls into the next month.
hourNumber0The hour from 0 to 23.
minuteNumber0The minute from 0 to 59.
secondNumber0The second from 0 to 59.
zoneString""The time zone to read it in. "exchange" (or "", the default) is the symbol's exchange zone, "chart" is the zone the chart displays, and you may also give "UTC" or an IANA name such as "America/New_York" or "Europe/London".

Returns

Number The time that the zone's clock shows as that date and time of day.

Details

Parts with decimals are cut to whole numbers. A wall time skipped when the clocks go forward (such as 02:30 on the spring change in New York) moves one hour on.

Units and time zones

A time in milliseconds since 1 January 1970 UTC, the same kind of number as time. A time is one instant everywhere; read its wall clock with clock.wall or clock.format. Zones: "" or "exchange" is the symbol's exchange zone (symbol.timezone, or UTC when the feed gives none); "chart" is the chart's display zone (the exchange zone when the chart does not say); "UTC" and IANA names such as "America/New_York" work too, and clock changes for summer time are handled for you. hour, minute, weekday, day, month and year accept "chart" and "exchange" as well.

Missing values

Any missing part gives missing.

Errors

  • NS405the zone is not "exchange", "chart", "UTC" or a time zone name the chart knows

Example

let w = clock.wall(time, zone = "America/New_York")
let open930 = clock.time(w.year, w.month, w.day, hour = 9, minute = 30, zone = "America/New_York")
plot("Minutes from 9:30", (time - open930) / 60000)

See also

clock.wallclock.offsettime

clock.offset

functionNexuScript 1.3

How many minutes a zone's clock is ahead of UTC at a given time.

Syntax

clock.offset(time::Number, zone::String = "") -> Number

Parameters

NameTypeDefaultDescription
timeNumberrequiredThe moment to ask about. The answer changes when the zone moves its clocks for summer time.
zoneString""The time zone to read it in. "exchange" (or "", the default) is the symbol's exchange zone, "chart" is the zone the chart displays, and you may also give "UTC" or an IANA name such as "America/New_York" or "Europe/London".

Returns

Number Minutes ahead of UTC: -240 for New York in summer, -300 in winter, 60 for London in summer. Negative west of UTC.

Units and time zones

The time is in milliseconds since 1 January 1970 UTC; the answer is in minutes. Zones: "" or "exchange" is the symbol's exchange zone (symbol.timezone, or UTC when the feed gives none); "chart" is the chart's display zone (the exchange zone when the chart does not say); "UTC" and IANA names such as "America/New_York" work too, and clock changes for summer time are handled for you. hour, minute, weekday, day, month and year accept "chart" and "exchange" as well.

Missing values

A missing time gives missing.

Errors

  • NS405the zone is not "exchange", "chart", "UTC" or a time zone name the chart knows

Example

plot("New York offset (hours)", clock.offset(time, zone = "America/New_York") / 60)

See also

clock.timeclock.exchange_zoneclock.wall

session.is_open

functionNexuScript 1.3

Tests whether the symbol's trading session is open on the chart clock.

Syntax

session.is_open() -> Bool

Returns

Bool true while the session is open at clock.now. Always true when the symbol has no session text.

Details

The session comes from symbol.session, on Monday to Friday, in the exchange zone. A perpetual (symbol.asset_class is "perps") and a symbol with no session text trade all the time, so the session is always open. Holidays and early closes are not known to the script.

Units and time zones

Read at clock.now, on the session's hours in the exchange zone (clock.exchange_zone).

Missing values

Never missing.

Live and historical bars

The chart clock never changes history. On a closed bar it is the bar's closing time. On the forming (newest, live) bar it is the time the chart gives with each price update, kept between the bar's open and close; when the chart gives no time, and always in a backtest, it is the bar's opening time. A script runs on each price update, so anything it shows from the clock refreshes with each update, not every second. Sessions are read at that clock, so on a closed bar they describe the moment the bar closed.

Example

if session.is_open == false
    background(color.fade(color.gray, 85))
end

See also

session.close_timesession.withinsymbol.session

session.open_time

functionNexuScript 1.3

When the current trading session opened, or when the next one opens while it is closed.

Syntax

session.open_time() -> Number

Returns

Number A time: the open of the session around clock.now, or of the next session when the market is closed.

Details

The session comes from symbol.session, on Monday to Friday, in the exchange zone. A perpetual (symbol.asset_class is "perps") and a symbol with no session text trade all the time, so the session is always open. Holidays and early closes are not known to the script.

Units and time zones

A time in milliseconds since 1 January 1970 UTC, the same kind of number as time. A time is one instant everywhere; read its wall clock with clock.wall or clock.format. Zones: "" or "exchange" is the symbol's exchange zone (symbol.timezone, or UTC when the feed gives none); "chart" is the chart's display zone (the exchange zone when the chart does not say); "UTC" and IANA names such as "America/New_York" work too, and clock changes for summer time are handled for you. hour, minute, weekday, day, month and year accept "chart" and "exchange" as well.

Missing values

missing when the symbol has no session text.

Live and historical bars

The chart clock never changes history. On a closed bar it is the bar's closing time. On the forming (newest, live) bar it is the time the chart gives with each price update, kept between the bar's open and close; when the chart gives no time, and always in a backtest, it is the bar's opening time. A script runs on each price update, so anything it shows from the clock refreshes with each update, not every second. Sessions are read at that clock, so on a closed bar they describe the moment the bar closed.

Example

if bar.last
    table([["Session opened", clock.format(session.open_time, "ddd HH:mm", zone = "chart")]])
end

See also

session.close_timesession.to_openperiod.starts

session.close_time

functionNexuScript 1.3

When the current trading session closes, or when the next one closes while it is closed.

Syntax

session.close_time() -> Number

Returns

Number A time: the close of the session around clock.now, or of the next session when the market is closed.

Details

The session comes from symbol.session, on Monday to Friday, in the exchange zone. A perpetual (symbol.asset_class is "perps") and a symbol with no session text trade all the time, so the session is always open. Holidays and early closes are not known to the script.

Units and time zones

A time in milliseconds since 1 January 1970 UTC, the same kind of number as time. A time is one instant everywhere; read its wall clock with clock.wall or clock.format. Zones: "" or "exchange" is the symbol's exchange zone (symbol.timezone, or UTC when the feed gives none); "chart" is the chart's display zone (the exchange zone when the chart does not say); "UTC" and IANA names such as "America/New_York" work too, and clock changes for summer time are handled for you. hour, minute, weekday, day, month and year accept "chart" and "exchange" as well.

Missing values

missing when the symbol has no session text.

Live and historical bars

The chart clock never changes history. On a closed bar it is the bar's closing time. On the forming (newest, live) bar it is the time the chart gives with each price update, kept between the bar's open and close; when the chart gives no time, and always in a backtest, it is the bar's opening time. A script runs on each price update, so anything it shows from the clock refreshes with each update, not every second. Sessions are read at that clock, so on a closed bar they describe the moment the bar closed.

Example

if bar.last
    table([["Session closes", clock.format(session.close_time, "ddd HH:mm", zone = "chart")]])
end

See also

session.open_timesession.to_closesession.is_open

session.to_open

functionNexuScript 1.3

How long until the next trading session opens.

Syntax

session.to_open() -> Number

Returns

Number Milliseconds from clock.now to the next open. 0 while the session is open.

Details

The session comes from symbol.session, on Monday to Friday, in the exchange zone. A perpetual (symbol.asset_class is "perps") and a symbol with no session text trade all the time, so the session is always open. Holidays and early closes are not known to the script.

Units and time zones

Milliseconds. Divide by 1000 for seconds or by 60000 for minutes.

Missing values

Never missing: 0 while open, and 0 when the symbol has no session text.

Live and historical bars

The chart clock never changes history. On a closed bar it is the bar's closing time. On the forming (newest, live) bar it is the time the chart gives with each price update, kept between the bar's open and close; when the chart gives no time, and always in a backtest, it is the bar's opening time. A script runs on each price update, so anything it shows from the clock refreshes with each update, not every second. Sessions are read at that clock, so on a closed bar they describe the moment the bar closed.

Example

plot("Hours to the open", session.to_open / 3600000)

See also

session.open_timesession.to_closesession.is_open

session.to_close

functionNexuScript 1.3

How long is left until the current trading session closes.

Syntax

session.to_close() -> Number

Returns

Number Milliseconds from clock.now to the session's close.

Details

The session comes from symbol.session, on Monday to Friday, in the exchange zone. A perpetual (symbol.asset_class is "perps") and a symbol with no session text trade all the time, so the session is always open. Holidays and early closes are not known to the script.

Units and time zones

Milliseconds. Divide by 1000 for seconds or by 60000 for minutes.

Missing values

missing while the session is closed, and when the symbol has no session text.

Live and historical bars

The chart clock never changes history. On a closed bar it is the bar's closing time. On the forming (newest, live) bar it is the time the chart gives with each price update, kept between the bar's open and close; when the chart gives no time, and always in a backtest, it is the bar's opening time. A script runs on each price update, so anything it shows from the clock refreshes with each update, not every second. Sessions are read at that clock, so on a closed bar they describe the moment the bar closed.

Example

plot("Minutes to the session close", session.to_close / 60000)

See also

session.close_timesession.to_openclock.to_close