Skip to content
ChartDeck ChartScript docs Account Open the terminal

tip

Tooltip cards. A tooltip is a string; the tip.* functions write a structured card into it: a title, badges, rows of label and value, checks, pages, a reward-to-risk bar, a mini line, a stat grid and an icon. Start with tip.card and add the parts with +. The chart draws the card in its own theme; a script never supplies markup, colours or pictures.

#Functions

#tip.badgefunction

A small pill beside the title (4 at most), in a tone when one is given.

tip.badge(text: string, { tone?: string = "" }): string
ParameterTypeDescription
textstringThe badge text, 20 characters at most.
tonestringdefault ""A tone: tip.up, tip.down, tip.warn, tip.muted or tip.accent ("" = none). The theme gives the colour.

Returns string.

Example

ChartScriptFragmentOpen in editor
if (barstate.islast) {
    const t = tip.card("Long setup") + tip.badge("1.4R", tip.up)
    label.new(bar_index, high, "L", { tooltip: t })
}

Since ChartScript 1

#tip.barfunction

A progress bar: value between min and max (4 bars at most per page, tip.rr included).

tip.bar(value: float, min: float, max: float, { tone?: string = "" }): string
ParameterTypeDescription
valuefloatThe value to show between min and max.
minfloatThe value at the empty end of the bar.
maxfloatThe value at the full end of the bar (above min).
tonestringdefault ""A tone: tip.up, tip.down, tip.warn, tip.muted or tip.accent ("" = none). The theme gives the colour.

Returns string.

Example

ChartScriptFragmentOpen in editor
if (barstate.islast) {
    const t = tip.card("Long setup") + tip.bar(ta.rsi(close, 14), 0, 100, tip.accent)
    label.new(bar_index, high, "L", { tooltip: t })
}

Since ChartScript 1

#tip.bulletfunction

One bullet point.

tip.bullet(text: string): string
ParameterTypeDescription
textstringThe text. Markup characters in it are escaped, so it is shown exactly as given.

Returns string.

Example

ChartScriptFragmentOpen in editor
if (barstate.islast) {
    const t = tip.card("Long setup") + tip.bullet("Trend up") + tip.bullet("Volume rising")
    label.new(bar_index, high, "L", { tooltip: t })
}

Since ChartScript 1

#tip.cardfunction

Starts a tooltip card and returns its first lines; add the other tip.* parts with + and pass the result as a tooltip (label.new, table.cell, tag.new, drawing.position). A tooltip that does not start with tip.card is shown as plain text.

tip.card(title: string, { sub?: string = "", rotate?: int = 0 }): string
ParameterTypeDescription
titlestringThe card title: one line, 80 characters at most ("" = a card without a header).
substringdefault ""A subtitle under the title ("" = none), 80 characters at most.
rotateintdefault 0Milliseconds per page for a card with pages; 0 (the default) = the pages change only by hand. 2500 at least, 20000 at most.

Returns string.

Example

ChartScriptFragmentOpen in editor
if (barstate.islast) {
    const t = tip.card("Long setup", { sub: "Demand zone held twice" }) + tip.row("Stop", str.tostring(low, "#.##"))
    label.new(bar_index, high, "L", { tooltip: t })
}

Since ChartScript 1

#tip.checkfunction

One line of a checklist: passed (true), failed (false) or, with no state, neutral.

tip.check(text: string): string
tip.check(text: string, state: bool): string
ParameterTypeDescription
textstringThe text. Markup characters in it are escaped, so it is shown exactly as given.
statebooltrue = passed, false = failed; left out = neutral (shown, not counted).

Returns string.

Example

ChartScriptFragmentOpen in editor
if (barstate.islast) {
    const t = tip.card("Long setup") + tip.check("Above the 200 EMA", close > ta.ema(close, 200)) + tip.check("Open interest: not on this market")
    label.new(bar_index, high, "L", { tooltip: t })
}

Since ChartScript 1

#tip.dividerfunction

A thin line between parts.

tip.divider(): string

Returns string.

Example

ChartScriptFragmentOpen in editor
if (barstate.islast) {
    const t = tip.card("Long setup") + tip.text("Entry on the close") + tip.divider() + tip.note("Example only")
    label.new(bar_index, high, "L", { tooltip: t })
}

Since ChartScript 1

#tip.footerfunction

The footer (one per card), fixed at the bottom of the card while its body scrolls.

tip.footer(text: string): string
ParameterTypeDescription
textstringThe text. Markup characters in it are escaped, so it is shown exactly as given.

Returns string.

Example

ChartScriptFragmentOpen in editor
if (barstate.islast) {
    const t = tip.card("Long setup") + tip.footer("Not a tested edge.")
    label.new(bar_index, high, "L", { tooltip: t })
}

Since ChartScript 1

#tip.iconfunction

A built-in icon beside the title. Pictures from the internet are not possible in a tooltip.

tip.icon(name: string, { tone?: string = "" }): string
ParameterTypeDescription
namestringAn icon of the built-in set: target, stop, flag, bolt, clock, warning, check, cross, up, down, flat, volume, liquidity, news, calendar, star, info, shield, rocket, fire, eye, lock, chart, coin. Another name draws nothing.
tonestringdefault ""A tone: tip.up, tip.down, tip.warn, tip.muted or tip.accent ("" = none). The theme gives the colour.

Returns string.

Example

ChartScriptFragmentOpen in editor
if (barstate.islast) {
    const t = tip.card("Long setup") + tip.icon("target")
    label.new(bar_index, high, "L", { tooltip: t })
}

Since ChartScript 1

#tip.notefunction

A muted note.

tip.note(text: string): string
ParameterTypeDescription
textstringThe text. Markup characters in it are escaped, so it is shown exactly as given.

Returns string.

Example

ChartScriptFragmentOpen in editor
if (barstate.islast) {
    const t = tip.card("Long setup") + tip.note("Shown only, not counted.")
    label.new(bar_index, high, "L", { tooltip: t })
}

Since ChartScript 1

#tip.pagefunction

Starts a page: the parts that follow belong to it until the next tip.page. A card holds 6 pages at most; the reader changes pages with the tabs, the arrow keys, the mouse wheel or a swipe.

tip.page(title: string): string
ParameterTypeDescription
titlestringThe page title shown on its tab, 24 characters at most.

Returns string.

Example

ChartScriptFragmentOpen in editor
if (barstate.islast) {
    const t = tip.card("Long setup") + tip.page("Signal") + tip.text("Why it fired") + tip.page("Risk") + tip.rr(close - low, high - close)
    label.new(bar_index, high, "L", { tooltip: t })
}

Since ChartScript 1

#tip.rotatefunction

Lets the pages change by themselves every ms milliseconds while the pointer rests on the label. It stops when the pointer is on the card, when the card is pinned, after a step by hand, and always when the reader asked for reduced motion.

tip.rotate(ms: int): string
ParameterTypeDescription
msintMilliseconds per page: 2500 at least, 20000 at most; 0 or na = no rotation.

Returns string.

Example

ChartScriptFragmentOpen in editor
if (barstate.islast) {
    const t = tip.card("Long setup") + tip.page("Signal") + tip.text("Why") + tip.page("Risk") + tip.text("How much") + tip.rotate(4000)
    label.new(bar_index, high, "L", { tooltip: t })
}

Since ChartScript 1

#tip.rowfunction

A row with a muted label on the left and a right-aligned value, in a tone when one is given.

tip.row(label: string, value: string, { tone?: string = "" }): string
ParameterTypeDescription
labelstringThe label on the left, 40 characters at most.
valuestringThe value, right-aligned (60 characters at most): format numbers with str.tostring.
tonestringdefault ""A tone: tip.up, tip.down, tip.warn, tip.muted or tip.accent ("" = none). The theme gives the colour.

Returns string.

Example

ChartScriptFragmentOpen in editor
if (barstate.islast) {
    const t = tip.card("Long setup") + tip.row("Stop", str.tostring(low, "#.##")) + tip.row("Target", str.tostring(high, "#.##"), tip.up)
    label.new(bar_index, high, "L", { tooltip: t })
}

Since ChartScript 1

#tip.rrfunction

A reward-to-risk bar drawn from two positive numbers, with the ratio in the middle.

tip.rr(risk: float, reward: float): string
ParameterTypeDescription
riskfloatThe risk as a positive number (the distance from the entry to the stop).
rewardfloatThe reward as a positive number (the distance from the entry to the target).

Returns string.

Example

ChartScriptFragmentOpen in editor
if (barstate.islast) {
    const t = tip.card("Long setup") + tip.rr(close - low, 2 * (close - low))
    label.new(bar_index, high, "L", { tooltip: t })
}

Since ChartScript 1

#tip.sectionfunction

A small uppercase heading above the parts that follow.

tip.section(title: string): string
ParameterTypeDescription
titlestringThe section heading, 80 characters at most.

Returns string.

Example

ChartScriptFragmentOpen in editor
if (barstate.islast) {
    const t = tip.card("Long setup") + tip.section("Checks") + tip.check("Volume above average", true)
    label.new(bar_index, high, "L", { tooltip: t })
}

Since ChartScript 1

#tip.sparkfunction

A mini line of the last numbers of an array (2 per card at most).

tip.spark(values: array<num>, { tone?: string = "" }): string
ParameterTypeDescription
valuesarray<num>An array of numbers, oldest first; the last 60 are drawn (na values are skipped; fewer than 2 draws nothing).
tonestringdefault ""A tone: tip.up, tip.down, tip.warn, tip.muted or tip.accent ("" = none). The theme gives the colour.

Returns string.

Example

ChartScriptFragmentOpen in editor
state last: array<float> = array.new_float()
last.push(close)
if (last.size() > 30) {
    last.shift()
}
if (barstate.islast) {
    const t = tip.card("Last 30 closes") + tip.spark(last, tip.accent)
    label.new(bar_index, high, "S", { tooltip: t })
}

Since ChartScript 1

#tip.statfunction

One cell of a stat grid: a big value over a small label. Cells written one after another form one grid, three to a row (9 at most per page).

tip.stat(value: string, label: string, { tone?: string = "" }): string
ParameterTypeDescription
valuestringThe big text of the cell (16 characters at most): format numbers with str.tostring.
labelstringThe small text under the value, 24 characters at most.
tonestringdefault ""A tone: tip.up, tip.down, tip.warn, tip.muted or tip.accent ("" = none). The theme gives the colour.

Returns string.

Example

ChartScriptFragmentOpen in editor
if (barstate.islast) {
    const t = tip.card("Long setup") + tip.stat("58%", "Won") + tip.stat("0.4R", "Per trade", tip.up) + tip.stat("22", "Days")
    label.new(bar_index, high, "L", { tooltip: t })
}

Since ChartScript 1

#tip.textfunction

A paragraph. Line breaks in the text are kept; each line holds 400 characters at most.

tip.text(text: string): string
ParameterTypeDescription
textstringThe text. Markup characters in it are escaped, so it is shown exactly as given.

Returns string.

Example

ChartScriptFragmentOpen in editor
if (barstate.islast) {
    const t = tip.card("Long setup") + tip.text("The zone held twice in the last hour.")
    label.new(bar_index, high, "L", { tooltip: t })
}

Since ChartScript 1

#Constants

NameTypeDescription
tip.accentstringThe accent tone.
tip.downstringThe tone of a loss (the theme's down colour).
tip.mutedstringThe muted tone.
tip.upstringThe tone of a gain (the theme's up colour).
tip.warnstringThe tone of a warning.

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