How a line or box continues past its anchor points: extend.none, extend.left, extend.right or extend.both.
extend.* constants go in the extend argument of line.new, box.new and their set_extend functions. extend.none stops the object at its anchor points and is the default. extend.right runs it to the right edge of the chart, extend.left to the left edge, and extend.both across the whole chart.
The direction is relative to the chart, not the line: extend.right continues past whichever of the two points is further right.
Constants
| Name | Value | Description |
|---|---|---|
extend.both | Continue in both directions, across the whole chart. | |
extend.left | Continue to the left edge of the chart. | |
extend.none | Stop at the anchor points; the default. | |
extend.right | Continue to the right edge of the chart. |
Remarks
- An extended line keeps following new bars on the right as they arrive.
Example
//@version=6
indicator("Extended high", overlay = true)
top = ta.highest(high, 100)
bottom = ta.lowest(low, 100)
if barstate.islast
line.new(bar_index - 100, top, bar_index, top, extend = extend.right, color = color.red, style = line.style_dashed)
line.new(bar_index - 100, bottom, bar_index, bottom, extend = extend.both, color = color.green)
plot(close, "Close", color.gray)See also
Runs on Sidechair