Recolors a whole line, or hides it with na.
The new color applies along the full length, extensions included. color.new(c, transparency) gives a faded line, and na keeps the object but draws nothing.
Because line.all reaches every line, one loop can restyle lines created on earlier bars.
Syntax
line.set_color(id: series line, color: series color) -> void
line.set_color(color: series color) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | series line | required | The line to recolor. na is accepted and ignored. |
| color | series color | required | New line color. color.new(c, 70) gives a faded line; na hides it while the object stays on the chart. |
Returns
Nothing.
Example
//@version=6
indicator("line.set_color: fade with age", overlay = true)
if bar_index % 20 == 0
line.new(bar_index, low, bar_index + 15, low, color = color.blue, width = 2)
for ln in line.all
line.set_color(ln, color.new(color.blue, math.min(90, bar_index - line.get_x1(ln))))See also
Runs on Sidechair