line, label, box, polyline or linefill (and a table).
Unlike a plot, a drawing can be created on some bars only, inside if, loops and functions, at positions you compute.
Create
x values are bar indexes (bar_index) by default, or times in milliseconds with xloc=xloc.bar_time; y values are prices.
extend is extend.none, left, right or both. Styles are constants: line.style_solid, dashed, dotted, arrow_left,
arrow_right, arrow_both; label.style_label_up, label_down, label_left, label_right, label_center, arrowup,
arrowdown, circle, square, diamond, flag, cross and others.
force_overlay on every call except line.new, which spells it forceOverlay. The other spelling is refused (The line.new() function does not accept a named argument force_overlay.).
Change and delete
Lines, labels and boxes haveset_* functions (line.set_xy2, label.set_text, label.set_style, box.set_right, line.set_color, …) and get_* readers
(line.get_y1, label.get_x, …); a linefill has linefill.set_color. Call them as functions or as methods: line.set_color(l, c) and l.set_color(c) are the same,
except that line.set_xloc(l, xloc.bar_time, time, time + 1) is a function only: the method l.set_xloc(...) takes just the xloc.
A polyline has no setters or getters: delete it and create a new one. delete removes any drawing, and copy (line, label and box) makes a new one with the same properties. There is no field
access: l.x is refused.
To update one drawing on later bars, keep it in a static variable, so it survives from bar to bar:
array<line> (or label, box) and delete the oldest, as in Arrays.
linefill.new shades between two lines; keep the talib calls outside the if:
Chart points and polylines
AchartPoint holds a time, a bar index and a price. Build one with chartPoint.from_index(index, price),
chartPoint.from_time(time, price), chartPoint.new(time, index, price) or chartPoint.now(price). line.new, box.new and
label.set_point have forms that take points. polyline.new takes an array of at most 1000 of them (more, or none, gives na); fill it with array.push, because
array.from does not accept chart points.
How many a script keeps
indicator() and strategy() take max_lines_count, max_labels_count, max_boxes_count and max_polylines_count (const
integers): 50 of each kind by default, 500 at most (100 for polylines; see Limits). Linefills stay at 50 and tables at 9.
When a kind goes a few above its limit, the oldest drawings of that kind are deleted until the limit is met. A line, label, box or
linefill that a static variable holds directly is never deleted this way; drawings held only in an array, and polylines, are, so keep
an array no longer than the limit. Raise the limit when the script needs more drawings on the chart: indicator("Many levels", overlay=true, max_lines_count=500).