Skip to content
ChartDeck ChartScript docs Account Open the terminal

cal

The economic calendar (ChartDeck’s calendar: US releases from the publishers’ own schedules, central banks and other countries from Forex Factory): when events happen, around each bar. Every plan. A bar sees the schedule as ChartDeck holds it; in Bar replay only the events at or before the replay time exist, as the chart’s calendar marks.

#Functions

#cal.actualfunction

The released figure of the series’ last event, once it was published (at or before the bar’s close); na before, and for series ChartDeck shows no figure of.

cal.actual(series: string): float
ParameterTypeDescription
seriesstringThe series id, for example "US.CPI.YOY" or "US.NFP".

Returns float.

Example

ChartScriptFragmentOpen in editor
plot(cal.actual("US.CPI.YOY"), "CPI y/y", color.accent, { style: plot.style_stepline })

Since ChartScript 1

#cal.forecastfunction

The forecast of the series’ last event at or before the bar’s close; na without one.

cal.forecast(series: string): float
ParameterTypeDescription
seriesstringThe series id.

Returns float.

Example

ChartScriptFragmentOpen in editor
const fc = cal.forecast("US.CPI.YOY")

Since ChartScript 1

#cal.in_barfunction

true when an event of the filter is scheduled inside this bar (from its open to its close).

cal.in_bar({ country?: string = "", importance?: int = cal.high, series?: string = "" }): bool
ParameterTypeDescription
countrystringdefault ""The country or area: "US", "EU", "GB", "JP", "CN", "CA", "AU", "NZ", "CH" or "CRYPTO"; "" = any.
importanceintdefault cal.highThe lowest importance counted: cal.low (1), cal.medium (2) or cal.high (3, the default).
seriesstringdefault ""A series id ("US.CPI.YOY") or the start of one ("US.FOMC" = every FOMC event); "" = any.

Returns bool.

Example

ChartScriptFragmentOpen in editor
bgcolor(cal.in_bar("US", cal.high) ? color.new(color.accent, 85) : na)

Since ChartScript 1

#cal.in_weekfunction

true when the bar’s UTC week (Monday to Sunday) holds an event of the filter: cal.in_week(cal.high, "US", "US.FOMC.DECISION") marks FOMC weeks.

cal.in_week({ importance?: int = cal.high, country?: string = "", series?: string = "" }): bool
ParameterTypeDescription
importanceintdefault cal.highThe lowest importance counted: cal.low (1), cal.medium (2) or cal.high (3, the default).
countrystringdefault ""The country or area: "US", "EU", "GB", "JP", "CN", "CA", "AU", "NZ", "CH" or "CRYPTO"; "" = any.
seriesstringdefault ""A series id ("US.CPI.YOY") or the start of one ("US.FOMC" = every FOMC event); "" = any.

Returns bool.

Example

ChartScriptFragmentOpen in editor
const fomcWeek = cal.in_week(cal.high, "US", "US.FOMC.DECISION")

Since ChartScript 1

#cal.in_windowfunction

true when the bar overlaps the window around an event of the filter: from minutes_before before it to minutes_after after it.

cal.in_window({ minutes_before?: int = 60, minutes_after?: int = 60, importance?: int = cal.high, country?: string = "", series?: string = "" }): bool
ParameterTypeDescription
minutes_beforeintdefault 60Minutes before the event the window opens.
minutes_afterintdefault 60Minutes after the event the window closes.
importanceintdefault cal.highThe lowest importance counted: cal.low (1), cal.medium (2) or cal.high (3, the default).
countrystringdefault ""The country or area: "US", "EU", "GB", "JP", "CN", "CA", "AU", "NZ", "CH" or "CRYPTO"; "" = any.
seriesstringdefault ""A series id ("US.CPI.YOY") or the start of one ("US.FOMC" = every FOMC event); "" = any.

Returns bool.

Example

ChartScriptFragmentOpen in editor
const quiet = !cal.in_window(30, 60, cal.high, "US")

Since ChartScript 1

#cal.minutes_to_nextfunction

Whole minutes from the bar’s close (the live bar: from now) to the next event of the filter; na when none is scheduled.

cal.minutes_to_next({ importance?: int = cal.high, country?: string = "", series?: string = "" }): int
ParameterTypeDescription
importanceintdefault cal.highThe lowest importance counted: cal.low (1), cal.medium (2) or cal.high (3, the default).
countrystringdefault ""The country or area: "US", "EU", "GB", "JP", "CN", "CA", "AU", "NZ", "CH" or "CRYPTO"; "" = any.
seriesstringdefault ""A series id ("US.CPI.YOY") or the start of one ("US.FOMC" = every FOMC event); "" = any.

Returns int.

Example

ChartScriptFragmentOpen in editor
const wait = cal.minutes_to_next(cal.high, "US")

Since ChartScript 1

#cal.next_namefunction

The name of the next event of the filter ("CPI y/y"); empty when none is scheduled.

cal.next_name({ importance?: int = cal.high, country?: string = "", series?: string = "" }): string
ParameterTypeDescription
importanceintdefault cal.highThe lowest importance counted: cal.low (1), cal.medium (2) or cal.high (3, the default).
countrystringdefault ""The country or area: "US", "EU", "GB", "JP", "CN", "CA", "AU", "NZ", "CH" or "CRYPTO"; "" = any.
seriesstringdefault ""A series id ("US.CPI.YOY") or the start of one ("US.FOMC" = every FOMC event); "" = any.

Returns string.

Example

ChartScriptFragmentOpen in editor
legend.info("Next: " + cal.next_name(cal.high, "US"))

Since ChartScript 1

#cal.next_timefunction

The time (ms) of the next event of the filter after the bar’s close (the live bar: after now); na when none is scheduled.

cal.next_time({ importance?: int = cal.high, country?: string = "", series?: string = "" }): int
ParameterTypeDescription
importanceintdefault cal.highThe lowest importance counted: cal.low (1), cal.medium (2) or cal.high (3, the default).
countrystringdefault ""The country or area: "US", "EU", "GB", "JP", "CN", "CA", "AU", "NZ", "CH" or "CRYPTO"; "" = any.
seriesstringdefault ""A series id ("US.CPI.YOY") or the start of one ("US.FOMC" = every FOMC event); "" = any.

Returns int.

Example

ChartScriptFragmentOpen in editor
const nextAt = cal.next_time(cal.high, "US")

Since ChartScript 1

#cal.prev_namefunction

The name of the last event of the filter at or before the bar’s close; empty when there is none.

cal.prev_name({ importance?: int = cal.high, country?: string = "", series?: string = "" }): string
ParameterTypeDescription
importanceintdefault cal.highThe lowest importance counted: cal.low (1), cal.medium (2) or cal.high (3, the default).
countrystringdefault ""The country or area: "US", "EU", "GB", "JP", "CN", "CA", "AU", "NZ", "CH" or "CRYPTO"; "" = any.
seriesstringdefault ""A series id ("US.CPI.YOY") or the start of one ("US.FOMC" = every FOMC event); "" = any.

Returns string.

Example

ChartScriptFragmentOpen in editor
const last = cal.prev_name(cal.high, "US")

Since ChartScript 1

#cal.prev_timefunction

The time (ms) of the last event of the filter at or before the bar’s close (the live bar: now); na when there is none.

cal.prev_time({ importance?: int = cal.high, country?: string = "", series?: string = "" }): int
ParameterTypeDescription
importanceintdefault cal.highThe lowest importance counted: cal.low (1), cal.medium (2) or cal.high (3, the default).
countrystringdefault ""The country or area: "US", "EU", "GB", "JP", "CN", "CA", "AU", "NZ", "CH" or "CRYPTO"; "" = any.
seriesstringdefault ""A series id ("US.CPI.YOY") or the start of one ("US.FOMC" = every FOMC event); "" = any.

Returns int.

Example

ChartScriptFragmentOpen in editor
const lastAt = cal.prev_time(cal.high, "US")

Since ChartScript 1

#cal.previousfunction

The previous figure of the series’ last event at or before the bar’s close; na without one.

cal.previous(series: string): float
ParameterTypeDescription
seriesstringThe series id.

Returns float.

Example

ChartScriptFragmentOpen in editor
const pv = cal.previous("US.CPI.YOY")

Since ChartScript 1

#cal.sincefunction

The time (ms) of the oldest calendar event ChartDeck gave this script, na when it gave none.

cal.since(): int

Returns int.

Example

ChartScriptFragmentOpen in editor
const from = cal.since()

Since ChartScript 1

#Constants

NameTypeDescription
cal.highintImportance 3 (high).
cal.lowintImportance 1 (low).
cal.mediumintImportance 2 (medium).

The ChartScript documentation is in English for now; translations will follow.