Drawing
4 entries. What each one takes, what it returns, and a working example.
box(bar1, price1, bar2, price2, color?, text?)
Draws a rectangle region.
Does not return a value; adds a rectangular region with the given corners.
Note
The price arguments may be series. For highlighting a supply/demand zone, a consolidation range or an event window.
Limits
bar1 and bar2 must each be a single NUMBER → drawing in bulk with a series (barIndex) raises an error; call it inside an if block, where the bar value collapses to a scalar. The price arguments may be series. Many boxes slow the chart down (there is a count limit).
box(0, highest(high, 50), 50, lowest(low, 50), "#2962ff", "zone") plot(close)
Frames the high-low range of the first 50 bars with a box labelled "bolge".
Shows an info/score table in a corner.
Does not return a value; adds a text panel in the top-right corner with the rows.
Note
Each argument becomes a row. Build rows with text to embed live values. There is one panel per call site: even when the code calls it on every bar, a single panel is drawn and it shows the values from the last bar.
Each argument becomes a row. Build rows with text to embed live values; usually called once on the last bar.
if barstate.islast { infoTable(text("Close: {0}", close), text("RSI: {0}", rsi(close, 14))) } plot(close)
On the last bar shows close and RSI values in a two-row panel.
label(price, text, bar?, color?, style?, size?)
Places a text box at a given price and bar position on the chart. Without a bar it lands on the last one. ⚠ The bar value must be a single number: instead of calling it on every bar, call it inside an `if` only where it is needed. Many labels slow the chart down and there is a count limit.
Returns nothing; it draws a text label box onto the chart.
Note
Usually called inside a conditional block: if condition { label(...) }. This way the bar index becomes a scalar and dynamic text (str.tostring) can be used. Use in text to split the label across multiple lines, which also shifts it to avoid overlapping another marker. Call the label inside a conditional block (if cond { ... }) so the bar index resolves to a single value and the text can show the current reading.
When to use
To show free text or a dynamic value (a price, a number). Use plotshape for a fixed shape and tableNew for a fixed-position panel.
Limits
The bar value must be a single number → passing a series (bar_index) directly in a vector run fails; call it bar by bar inside an if block. Many labels hurt performance (there is a count limit).
Not for
Not for a fixed shape repeated on every bar — plotshape/plotchar are lighter for that. For a summary that stays pinned in a corner and does not scroll, use tableNew. Do not create a label on a great many bars; you will hit the count limit and slow the chart down.
Tip
Call the label inside a conditional block (if cond {... }) so the bar index resolves to a single value and the text can show the current reading.
Usually called inside a conditional block: if condition { label(...) }. This way the bar index becomes a scalar and dynamic text (str.tostring) can be used. Use in text to split the label across multiple lines, which also shifts it to avoid overlapping another marker.
Call the label inside a conditional block (if cond { ... }) so the bar index resolves to a single value and the text can show the current reading.
if crossover(close, sma(close,10)) { label(low, "AL", barIndex, color="#26a69a", style="labelup") }
A green 'BUY' label at the low level on every cross-above bar.
if barstate.islast { label(close, "Last: " + str.tostring(close), last_bar_index) }
A dynamic label showing the closing price on the last bar.
trendline(bar1, price1, bar2, price2, color?, style?)
Trend line between two points (bar-offset: 0=last, negative=past).
Does not return a value; adds a straight line between the two points.
Note
The price arguments may be series; then the value at the relevant bar is used. For placing trend, support/resistance or channel lines by hand.
Limits
bar1 and bar2 must each be a single NUMBER → drawing in bulk with a series (barIndex) raises an error; call it inside an if block, where the bar value collapses to a scalar. The price arguments may be series; the value at that bar is used. Many lines slow the chart down (there is a count limit).
trendline(0, low, 50, high) plot(close)
Draws a line from the first bar's low to bar 50's high.
trendline(0, lowest(low, 50), 50, highest(high, 50), "#26a69a", "dashed") plot(close)
Connects the low and high of the first 50 bars with a green dashed line.