Plotting

Visualize indicator data with plot functions, shapes, fills, and colors

Plot Functions

FunctionDescription
plot(series, title?, options?)Plot a line, area, histogram, or other series style
plotshape(series, title?, options?)Plot shape markers (arrows, circles, diamonds, etc.)
plotchar(series, title?, char?, options?)Plot character markers
plotarrow(series, title?, options?)Plot arrow markers
plotbar(open, high, low, close, title?, options?)Plot OHLC bars
plotcandle(open, high, low, close, title?, options?)Plot candlesticks
hline(price, title?, options?)Draw a horizontal line at a fixed price level
fill(plot1, plot2, color?)Fill the area between two plots
bgcolor(color, offset?, options?)Set background color for bars
barcolor(color, offset?, options?)Set bar color

Plot Styles

Use plot.style_* constants to control how data is rendered:

StyleDescription
plot.style_lineContinuous line (default)
plot.style_linebrLine with breaks at na values
plot.style_steplineStep line
plot.style_stepline_diamondStep line with diamond markers
plot.style_steplinebrStep line with breaks
plot.style_areaFilled area below the line
plot.style_areabrArea with breaks at na
plot.style_histogramVertical histogram bars
plot.style_columnsColumn chart
plot.style_circlesCircle markers
plot.style_crossCross markers

Line Styles (for plot and hline)

StyleDescription
plot.linestyle_solidSolid line
plot.linestyle_dashedDashed line
plot.linestyle_dottedDotted line
hline.style_solidSolid horizontal line
hline.style_dashedDashed horizontal line
hline.style_dottedDotted horizontal line

Examples

Basic Line Plot

indicator('EMA Crossover', { overlay: true });

const fast = ta.ema(close, 9);
const slow = ta.ema(close, 21);

plot(fast, 'Fast EMA', { color: '#2962FF' });
plot(slow, 'Slow EMA', { color: '#FF6D00' });

Histogram

indicator('MACD Histogram');

const [macdLine, signalLine, hist] = ta.macd(close, 12, 26, 9);

plot(hist, 'Histogram', {
  style: plot.style_histogram,
  color: hist > 0 ? '#26A69A' : '#EF5350'
});
plot(macdLine, 'MACD', { color: '#2962FF' });
plot(signalLine, 'Signal', { color: '#FF6D00' });

Fill Between Plots

indicator('Bollinger Bands', { overlay: true });

const [mid, upper, lower] = ta.bb(close, 20, 2);

const p1 = plot(upper, 'Upper', { color: '#F23645' });
plot(mid, 'Middle', { color: '#787B86' });
const p2 = plot(lower, 'Lower', { color: '#089981' });

fill(p1, p2);

Shape Markers

// Plot buy/sell arrows at crossover points
if (ta.crossover(fast, slow)) {
  plotshape(close, 'Buy', {
    style: shape.triangleup,
    location: location.belowbar,
    color: '#00FF00',
    size: size.small
  });
}

if (ta.crossunder(fast, slow)) {
  plotshape(close, 'Sell', {
    style: shape.triangledown,
    location: location.abovebar,
    color: '#FF0000',
    size: size.small
  });
}

Shape Constants

ConstantDescription
shape.triangleupUpward triangle
shape.triangledownDownward triangle
shape.circleCircle
shape.crossCross
shape.xcrossX-cross
shape.diamondDiamond
shape.squareSquare
shape.arrowupUpward arrow
shape.arrowdownDownward arrow
shape.flagFlag
shape.labelupLabel pointing up
shape.labeldownLabel pointing down

Location Constants

ConstantDescription
location.abovebarAbove the bar
location.belowbarBelow the bar
location.topTop of pane
location.bottomBottom of pane
location.absoluteAt the exact value

Size Constants

ConstantDescription
size.tinyTiny
size.smallSmall
size.normalNormal
size.largeLarge
size.hugeHuge
size.autoAutomatic

Background and Bar Colors

// Highlight bars based on condition
bgcolor(ta.crossover(fast, slow) ? '#00FF0020' : na);
barcolor(close > open ? '#26A69A' : '#EF5350');

Colors can be specified as hex strings (e.g., '#FF0000') or using the color namespace (e.g., color.red). Append two hex digits for alpha transparency (e.g., '#FF000080' for 50% opacity).