CODESCRIPT

Drawing

4 entries. What each one takes, what it returns, and a working example.

box(bar1, price1, bar2, price2, color?, text?)

Does not return a value; adds a rectangular region with the given corners.

bar1
number
The bar index of the left edge.
price1
number
The price of the top edge.
bar2
number
The bar index of the right edge.
price2
number
The price of the bottom edge.
color
color
Optional. The border color (default blue).
text
string
Optional. A label to write inside the box.
NOTE

The price arguments may be series. For highlighting a supply/demand zone, a consolidation range or an event window.

CODESCRIPT
box(0, highest(high, 50), 50, lowest(low, 50), "#2962ff", "bolge")
plot(close)

Frames the high-low range of the first 50 bars with a box labelled "bolge".

infoTable(...satırlar)

Does not return a value; adds a text panel in the top-right corner with the rows.

...satırlar
any
The rows to write into the panel (usually built with text).
NOTE

Each argument becomes a row. Build rows with text to embed live values; usually called once on the last bar.

CODESCRIPT
if barstate.islast {
  infoTable(text("Kapanis: {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?)

Returns nothing; it draws a text label box onto the chart.

price
number
Vertical position of the label (price).
text
string
Label text (per-bar scalar).
bar
number
Optional. Bar index (default current bar).
color
color
Optional. Background color.
style
string
Optional. labelup/labeldown etc.
size
string
Optional. Size.
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.

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.

CODESCRIPT
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.

CODESCRIPT
if barstate.islast {
  label(close, "Son: " + str.tostring(close), last_bar_index)
}

A dynamic label showing the closing price on the last bar.

trendline(bar1, price1, bar2, price2, color?, style?)

Does not return a value; adds a straight line between the two points.

bar1
number
The bar index of the first point.
price1
number
The price of the first point.
bar2
number
The bar index of the second point.
price2
number
The price of the second point.
color
color
Optional. The line color (default blue).
style
string
Optional. "solid", "dashed" or "dotted".
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.

CODESCRIPT
trendline(0, low, 50, high)
plot(close)

Draws a line from the first bar's low to bar 50's high.

CODESCRIPT
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.