Write
Plotting
Every way a script draws a series: plot styles, markers, reference lines, fills and colouring bars, on the price chart or in its own pane.
A script that computes something still needs to draw it. Pine's drawing functions take a series and turn it into lines, markers or colours on the chart.
Price chart or its own pane#
indicator("...", overlay = true) draws on the price chart. Leave overlay out (it defaults to false) and the script gets its own pane below the chart, with its own scale. Oscillators such as RSI belong in a pane; averages and bands belong on price.
A single script can still put one visual on the price chart from a pane with force_overlay = true on that call.
plot() and its styles#
//@version=6indicator("Plot styles")mom = ta.mom(close, 10)plot(mom, "Momentum", style = plot.style_columns, color = mom >= 0 ? color.new(color.teal, 30) : color.new(color.red, 30))plot(ta.sma(mom, 9), "Signal", color = color.orange, linewidth = 2)hline(0, "Zero", color = color.gray)| Style | Draws |
|---|---|
plot.style_line (default) | A continuous line |
plot.style_linebr | A line with gaps where the value is na |
plot.style_stepline | Steps instead of slopes |
plot.style_histogram | Thin bars from the base line |
plot.style_columns | Wide bars from the base line |
plot.style_area / style_areabr | A filled area |
plot.style_circles / style_cross | A dot or a cross per bar |
Useful arguments: linewidth, color (which can change per bar, as above), offset to shift the plot left or right, show_last to draw only the last N bars, and display = display.none to compute a plot without drawing it (handy as the input to a fill).
Markers: plotshape, plotchar, plotarrow#
Markers mark events, not values. plotshape draws a shape, plotchar draws a character, plotarrow draws an arrow sized by its value (positive up, negative down).
//@version=6indicator("RSI extremes", overlay = true)r = ta.rsi(close, 14)plotshape(ta.crossunder(r, 30), "Oversold", style = shape.circle, location = location.belowbar, color = color.teal, size = size.tiny)plotshape(ta.crossover(r, 70), "Overbought", style = shape.circle, location = location.abovebar, color = color.red, size = size.tiny)plotchar(ta.cross(close, ta.sma(close, 50)), "Cross 50", char = "x", location = location.top, color = color.orange)Locations: location.abovebar, location.belowbar, location.top, location.bottom, and location.absolute, which places the marker at the series value itself.
Reference lines and fills#
hline(price) draws a fixed horizontal line. fill(a, b, color) shades between two plots or two hlines; pass the objects those calls return.
//@version=6indicator("Bollinger fill", overlay = true)[mid, up, lo] = ta.bb(close, 20, 2)p1 = plot(up, "Upper", color = color.new(#8b7cff, 0))p2 = plot(lo, "Lower", color = color.new(#8b7cff, 0))plot(mid, "Basis", color = color.new(#ffb547, 0))fill(p1, p2, color = color.new(#8b7cff, 88), title = "Band")Colouring the chart itself#
bgcolor(color)tints the background of a bar.barcolor(color)recolours the candles.
//@version=6indicator("Trend tint", overlay = true)trendUp = ta.ema(close, 20) > ta.ema(close, 50)bgcolor(trendUp ? color.new(color.teal, 90) : color.new(color.red, 92))barcolor(close > open ? color.teal : color.red)Drawing candles#
plotcandle and plotbar draw your own OHLC series, for example Heikin Ashi computed by hand, in a pane or on price.
How close it is to TradingView#
Every style above is drawn natively. A few things are approximations rather than pixel-identical: some marker and label shapes, proportional arrow sizing, curved lines, and table layout. The numbers are exact; the shapes are close.