> ## Documentation Index
> Fetch the complete documentation index at: https://gocharting.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# polyline functions

> Reference for the 3 functions of the polyline namespace: polyline.all, polyline.delete and polyline.new, each with its definition and an example.

> [!NOTE]
>
> Language version: 2 · Reference version: 2.7 · Date: 2026-10-25 · Compiler build: df7b3b14 · Namespace: polyline · Entries: 4

## `polyline` (library)

**Definition**

Functions for creating and deleting multi-point polyline drawings from an array of chartPoint vertices.

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("polyline Library Example", overlay=true)
if barstate.islast {
    pts = array.new<chartPoint>(0)
    int i = 0
    while i <= 4 {
        array.push(pts, chartPoint.from_index(bar_index - i * 5, close[i * 5]))
        i := i + 1
    }
    polyline.new(pts, curved=true, line_color=color.purple, line_width=2)
}
```

## `polyline.all` (function)

**Definition**

Returns the array of all existing polyline objects (same as the polyline.all variable).

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
polyline.all() → series array<polyline>
```

**Returns**

`series array<polyline>`

An array of polyline IDs, oldest to newest.

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("polyline.all Function Example", overlay=true)
plot(array.length(polyline.all), title="Polylines")
```

## `polyline.delete` (function)

**Definition**

Deletes a polyline object.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
polyline.delete(series polyline id) → void
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `series polyline` | yes | Polyline object to delete. |

**Returns**

`void`

void

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("polyline.delete Example", overlay=true)
if barstate.islast {
    pts = array.new<chartPoint>(0)
    array.push(pts, chartPoint.from_index(bar_index[5], high[5]))
    array.push(pts, chartPoint.from_index(bar_index, close))
    p = polyline.new(pts)
    polyline.delete(p)
}
```

## `polyline.new` (function)

**Definition**

Creates a polyline from an array of chartPoint objects. The drawing is bar/price anchored via those points. A polyline holds at most 1000 vertices: with an empty array, or with more than 1000 points, the call draws nothing and returns `na`.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
polyline.new(series array<chartPoint> points, series bool curved, series bool closed, series string xloc, series color line_color, series color fill_color, series string line_style, series int line_width, const bool force_overlay) → series polyline
```

**Parameters**

| Name | Type | Required | Description | Values | Default |
| - | - | - | - | - | - |
| `points` | `series array<chartPoint>` | yes | Array of chartPoint vertices, in drawing order: at most 1000. An empty array, or one with more than 1000 points, makes the call return `na`. | | |
| `curved` | `series bool` | no | If true, connect points with a curve. Default is false. | | `false` |
| `closed` | `series bool` | no | If true, connect the last point back to the first. Default is false. | | `false` |
| `xloc` | `series string` | no | How x-coordinates are interpreted: xloc.bar\_index or xloc.bar\_time. Default is xloc.bar\_index. | `xloc.bar_index`, `xloc.bar_time` | `xloc.bar_index` |
| `line_color` | `series color` | no | Stroke color. Optional. | | `na` |
| `fill_color` | `series color` | no | Interior fill color when the polyline is closed. Optional. | | `na` |
| `line_style` | `series string` | no | Stroke style (line.style\_\*). Optional. | `line.style_arrow_both`, `line.style_arrow_left`, `line.style_arrow_right`, `line.style_dashed`, `line.style_dotted`, `line.style_solid` | `line.style_solid` |
| `line_width` | `series int` | no | Stroke width in pixels. Optional. | | `1` |
| `force_overlay` | `const bool` | no | If true, draw on the main pane even when the script is not overlay. Default is false. | | `false` |

**Returns**

`series polyline`

The ID of the created polyline, or na if points are invalid.

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("polyline.new Example", overlay=true)
if barstate.islast {
    pts = array.new<chartPoint>(0)
    array.push(pts, chartPoint.from_index(bar_index[20], low[20]))
    array.push(pts, chartPoint.from_index(bar_index[10], high[10]))
    array.push(pts, chartPoint.from_index(bar_index, close))
    polyline.new(pts, curved=false, closed=false, line_color=color.orange, line_width=2)
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.