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| Parameter | Type | Description |
|---|---|---|
series | string | The series id, for example "US.CPI.YOY" or "US.NFP". |
Returns float.
Example
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| Parameter | Type | Description |
|---|---|---|
series | string | The series id. |
Returns float.
Example
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| Parameter | Type | Description |
|---|---|---|
country | stringdefault "" | The country or area: "US", "EU", "GB", "JP", "CN", "CA", "AU", "NZ", "CH" or "CRYPTO"; "" = any. |
importance | intdefault cal.high | The lowest importance counted: cal.low (1), cal.medium (2) or cal.high (3, the default). |
series | stringdefault "" | A series id ("US.CPI.YOY") or the start of one ("US.FOMC" = every FOMC event); "" = any. |
Returns bool.
Example
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| Parameter | Type | Description |
|---|---|---|
importance | intdefault cal.high | The lowest importance counted: cal.low (1), cal.medium (2) or cal.high (3, the default). |
country | stringdefault "" | The country or area: "US", "EU", "GB", "JP", "CN", "CA", "AU", "NZ", "CH" or "CRYPTO"; "" = any. |
series | stringdefault "" | A series id ("US.CPI.YOY") or the start of one ("US.FOMC" = every FOMC event); "" = any. |
Returns bool.
Example
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| Parameter | Type | Description |
|---|---|---|
minutes_before | intdefault 60 | Minutes before the event the window opens. |
minutes_after | intdefault 60 | Minutes after the event the window closes. |
importance | intdefault cal.high | The lowest importance counted: cal.low (1), cal.medium (2) or cal.high (3, the default). |
country | stringdefault "" | The country or area: "US", "EU", "GB", "JP", "CN", "CA", "AU", "NZ", "CH" or "CRYPTO"; "" = any. |
series | stringdefault "" | A series id ("US.CPI.YOY") or the start of one ("US.FOMC" = every FOMC event); "" = any. |
Returns bool.
Example
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| Parameter | Type | Description |
|---|---|---|
importance | intdefault cal.high | The lowest importance counted: cal.low (1), cal.medium (2) or cal.high (3, the default). |
country | stringdefault "" | The country or area: "US", "EU", "GB", "JP", "CN", "CA", "AU", "NZ", "CH" or "CRYPTO"; "" = any. |
series | stringdefault "" | A series id ("US.CPI.YOY") or the start of one ("US.FOMC" = every FOMC event); "" = any. |
Returns int.
Example
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| Parameter | Type | Description |
|---|---|---|
importance | intdefault cal.high | The lowest importance counted: cal.low (1), cal.medium (2) or cal.high (3, the default). |
country | stringdefault "" | The country or area: "US", "EU", "GB", "JP", "CN", "CA", "AU", "NZ", "CH" or "CRYPTO"; "" = any. |
series | stringdefault "" | A series id ("US.CPI.YOY") or the start of one ("US.FOMC" = every FOMC event); "" = any. |
Returns string.
Example
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| Parameter | Type | Description |
|---|---|---|
importance | intdefault cal.high | The lowest importance counted: cal.low (1), cal.medium (2) or cal.high (3, the default). |
country | stringdefault "" | The country or area: "US", "EU", "GB", "JP", "CN", "CA", "AU", "NZ", "CH" or "CRYPTO"; "" = any. |
series | stringdefault "" | A series id ("US.CPI.YOY") or the start of one ("US.FOMC" = every FOMC event); "" = any. |
Returns int.
Example
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| Parameter | Type | Description |
|---|---|---|
importance | intdefault cal.high | The lowest importance counted: cal.low (1), cal.medium (2) or cal.high (3, the default). |
country | stringdefault "" | The country or area: "US", "EU", "GB", "JP", "CN", "CA", "AU", "NZ", "CH" or "CRYPTO"; "" = any. |
series | stringdefault "" | A series id ("US.CPI.YOY") or the start of one ("US.FOMC" = every FOMC event); "" = any. |
Returns string.
Example
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| Parameter | Type | Description |
|---|---|---|
importance | intdefault cal.high | The lowest importance counted: cal.low (1), cal.medium (2) or cal.high (3, the default). |
country | stringdefault "" | The country or area: "US", "EU", "GB", "JP", "CN", "CA", "AU", "NZ", "CH" or "CRYPTO"; "" = any. |
series | stringdefault "" | A series id ("US.CPI.YOY") or the start of one ("US.FOMC" = every FOMC event); "" = any. |
Returns int.
Example
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| Parameter | Type | Description |
|---|---|---|
series | string | The series id. |
Returns float.
Example
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(): intReturns int.
Example
const from = cal.since()Since ChartScript 1
#Constants
| Name | Type | Description |
|---|---|---|
cal.high | int | Importance 3 (high). |
cal.low | int | Importance 1 (low). |
cal.medium | int | Importance 2 (medium). |