priceLabel

Places a compact label right at a chosen price level and time. It’s great for tagging key levels (entries, stops, targets) so they stand out clearly on the chart without taking much space.

Syntax (one line)

priceLabel(time, price, styles?, text?)

Parameters

time (number) · Candle time where the label is anchored (e.g., time(0)). price (number) · Price level where the label sits (e.g., closeC(0)). styles (PriceLabelLineToolOverrides) · Visual options for the label box and text:

  • backgroundColor (RGBAColor | BaseColors) · Label background color.

  • borderColor (RGBAColor | BaseColors) · Border color of the label box.

  • color (RGBAColor | BaseColors) · Text color.

  • fontsize (number) · Font size of the label text.

  • fontWeight (string) · Text weight (e.g., "normal", "bold").

  • transparency (number) · 0–100 background transparency (higher = lighter). text (string) · Optional short label (e.g., "TP", "SL", "Entry").

Return Value

(string) · The drawing ID of the created Price Label.

Example

What this does: Every 40 candles, it pins a small label at the current close saying “Target,” with a soft background and thin border. All visuals live in one const style.

//@version=1
init = () => {
  indicator({ onMainPanel: true, format: 'inherit' });
};

onTick = () => {
  if (index % 40 === 0) { // draw occasionally to keep charts clean
    // 1) Style (PriceLabelLineToolOverrides)
    const style = {
      backgroundColor: color.rgba(0, 122, 255, 0.18),
      borderColor: color.rgba(0, 122, 255, 0.85),
      color: color.white,
      fontsize: 12,
      fontWeight: "bold",
      transparency: 82
    };

    // 2) Place the price label at this bar’s close
    priceLabel(time(0), closeC(0), style, "Target");
  }
};

Tips

  • Keep labels short (2–6 chars) so they don’t cover candles: e.g., “SL”, “TP”, “E”.

  • Use consistent colors for label types (green = entries, red = stops, blue = targets) to read charts faster.

Warning

  • Too many labels clustered at the same price can overlap—space them out or reduce frequency.

Good Practice

  • Store a few presets (Entry/Stop/Target) as const style objects for quick reuse.

  • Use a higher transparency to keep price action visible beneath the label.

Last updated