line
This adds a line on your chart that moves with your data. It’s the most common way to show things like moving averages, signals, or any custom calculation. For example, you can plot a 14-period moving average or draw your custom indicator line on top of price.
Syntax
plot.line(title, value, color, plottype?, id?)
Parameters
title
string— Name of the line (shown in settings).value
number— The number you want to plot (for example:close,sma,rsi).color
string— Line color, like"red"or"rgba(0,255,0,0.5)".plottype
number(optional) — How the line is drawn (usually just leave it as default).plottype- number, one of the following:0- line1- histogram3- cross4- area5- columns6- circles7- line with breaks8- area with breaks9- step line
id
string(optional) — Custom identifier (helpful if you want to link it later, for example withfilledArea).
Return Value
{ value: number; id: string } — Echoes the value and the final id assigned to the plot.
Example
Result

Tips
Give lines clear names like “Fast MA” or “RSI Signal” so users know what they see.
If you only need one line, don’t worry about
id. If you want to connect it with another plot (like filling the area between two lines), give it a customid.
Warning
If you name two lines the same, they’ll get the same id and might overwrite each other. Use unique names
or custom ids.
Last updated