Takes a line off the chart and frees its place in the drawing limit.
The line vanishes at once and drops out of line.all. The variable that held it still points at the old object, and deleting it again, or deleting na, does nothing.
To keep one line on the chart at a time, delete the previous line before creating the next. Deleting lines that have grown stale also keeps a script clear of the max_lines_count cap.
Syntax
line.delete(id: series line) -> void
line.delete() -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | series line | required | The line to remove from the chart. na is accepted and nothing happens. |
Returns
Nothing.
Remarks
- If the line is also stored in an array, remove it from the array too, with
array.remove()orarray.shift().
Example
//@version=6
indicator("line.delete: expire old lines", overlay = true)
if bar_index % 10 == 0
line.new(bar_index, close, bar_index + 8, close, color = color.blue)
for ln in line.all
if line.get_x1(ln) < bar_index - 120
line.delete(ln)See also
Runs on Sidechair