path
The path method lets you draw a free-form line across multiple points on the chart. It’s great for sketching out custom shapes, irregular ranges, or manually tracing price action with a continuous stroke.
Syntax (one line)
path(points, styles?)
Parameters
points (PricedData[]) · Array of points (each with time and price) defining the path.
styles (PathLineToolOverrides) · Options for customizing the look:
leftEnd(number) · Control how the left end of the path is rendered.lineColor(RGBAColor | BaseColors) · Path line color.lineStyle(number) · 0=solid, 1=dotted, 2=dashed, etc.lineWidth(number) · Thickness of the line.rightEnd(number) · Control how the right end of the path is rendered.
Return Value
(string) · The drawing ID of the created path.
Example
What this does: Every 80 candles, it traces a path connecting three recent swing points.
//@version=1
init = () => {
indicator({ onMainPanel: true, format: 'inherit' });
};
onTick = () => {
if (index % 80 === 0) { // draw occasionally
// 1) Define the points
const points = [
newPoint(time(90), high(90)), // older high
newPoint(time(60), low(60)), // middle low
newPoint(time(30), closeC(30)) // recent close
];
// 2) Style (PathLineToolOverrides)
const style = {
lineColor: color.orange,
lineStyle: 0,
lineWidth: 2,
leftEnd: 0,
rightEnd: 0
};
// 3) Draw the path
path(points, style);
}
};Tips
Use paths for manual drawings where standard tools don’t apply.
Connect multiple highs/lows to visualize a zig-zag or free-form range.
Warning
Adding too many points will create a messy or jagged line—keep paths simple for clarity.
Good Practice
Stick to a consistent color scheme for manual drawings (e.g., orange for notes, gray for sketches) so they don’t distract from key signals.
Last updated