Skip to content

002 — Your first indicator

In this lesson, we will create a simple line that follows the closing price.

//@version=6
indicator("Close Line", overlay = true)
plot(close, "Close", color = color.blue, linewidth = 2)

Copy the complete script into the Pine Editor and add it to a chart.

//@version=6

This tells TradingView to compile the script as Pine Script v6. Keep it on the first line.

indicator("Close Line", overlay = true)

Every Pine script needs one declaration statement.

  • "Close Line" is the indicator’s name.
  • overlay = true places the output in the main price chart.
  • With overlay = false, the indicator would normally use a separate pane.
plot(close, "Close", color = color.blue, linewidth = 2)

The arguments mean:

  • close: the value to draw on each bar
  • "Close": the plot title shown in settings and the data window
  • color = color.blue: the line color
  • linewidth = 2: the line thickness

Try each change separately:

plot(high, "High", color = color.orange, linewidth = 2)
plot(low, "Low", color = color.purple, linewidth = 3)

You can also plot more than one series:

//@version=6
indicator("High and Low", overlay = true)
plot(high, "High", color = color.green)
plot(low, "Low", color = color.red)

plot() does not draw one fixed line. Pine evaluates the supplied value on every bar. The plotted points are then connected across the chart.