Stickers

🧾 Overview

This example shows how to toggle stickers on the chart and place one every 30 candles. When enabled, it draws a Bitcoin sticker at the open price of the current bar.

🔍 What this example does

  • Adds a Show Sticker switch in init.

  • On each update, if the switch is on and the bar count hits a multiple of 30, it places a sticker on the chart.

init = () => {
  input.bool("Show Sticker", true, "show");
};

onTick = (length, _moment, _, ta, inputs) => {
  if (inputs.show && length % 30 === 0) {
    sticker(time(0), openC(0), StickersList.bitcoin);
  }
};

🧱 Key pieces explained

  • input.bool("Show Sticker", true, "show") Creates a toggle input (default on) and stores its value as inputs.show.

  • onTick = (length, _moment, _, ta, inputs) => { ... }

    • length: number of bars currently loaded (0‑indexed + 1 in practice).

    • inputs: object with your user inputs (e.g., inputs.show).

    • Other params (_moment, _, ta) are available utilities/placeholders in this signature.

  • length % 30 === 0 Triggers the action every 30 bars (30, 60, 90, …). Simple throttle to avoid spamming.

  • sticker(time(0), openC(0), StickersList.bitcoin) Draws a sticker at:

    • time(0): the timestamp of the current bar.

    • openC(0): the open price of the current bar.

    • StickersList.bitcoin: a predefined icon from the stickers list.

Warning

Last updated