polyline
Draws a Polyline by connecting multiple points with straight segments. It’s perfect for outlining custom zones, sketching patterns, or tracing price swings. You can optionally fill the interior to make areas stand out.
Syntax (one line)
polyline(points, styles?)
Parameters
points (PricedData[]) · Array of points (each with time & price) that define the connected segments.
styles (PolylineLineToolOverrides) · Visual and fill options:
backgroundColor(RGBAColor | BaseColors) · Fill color for the interior.fillBackground(boolean) · Turn background fill on/off.filled(boolean) · Close the shape and fill it (iffillBackgroundis true).linecolor(RGBAColor | BaseColors) · Line color for the outline.linestyle(number) · 0=solid, 1=dotted, 2=dashed…linewidth(number) · Outline thickness.transparency(number) · 0–100 fill transparency (higher = lighter).
Return Value
(string) · The drawing ID of the created Polyline.
Example
What this does: Every 44 candles, it traces a simple 3-point polyline around a recent swing and softly fills the area. All visuals live in one const style.
Tips
Add more points to follow complex swings, but keep shapes simple for readability.
For zones, set
filled: trueand use a high transparency so candles remain visible.
Warning
Very dense polylines can clutter the chart—avoid adding unnecessary points.
Good Practice
Use a consistent color for outline vs fill across all your custom shapes.
Keep a reusable
const styleand only tweaklinecolor/backgroundColorper scenario.
Last updated