Skip to content

Draws one or more series on the backtest chart, under a name. The value of the last call in each bar is drawn at that bar.

declare function plot(name: string, ...values: Array<number | [number, number] | PlotSeries | null>): void;
interface PlotSeries {
value: number | [number, number] | null;
name?: string;
color?: string;
type?: "line" | "spline" | "area" | "areaspline" | "bar" | "column" | "arearange" | "areasplinerange" | "columnrange";
dashStyle?: string;
lineWidth?: number;
opposite?: boolean;
overlay?: boolean;
precision?: number;
[option: string]: unknown;
}
  • name: the name of the plot, shown in the legend.
  • values: up to 10 per plot. Each is a number (a line over the price), an array of two numbers (a shaded range), null (a gap), or an object with a value and display settings:
Setting Meaning
value The number or the two-number range to draw. Required.
name The series name, when a plot draws several.
type "spline" (the default), "line", "area", "areaspline", "bar" or "column"; for a range, "areasplinerange" (the default), "arearange" or "columnrange".
overlay false draws the series in its own panel below the price.
opposite true gives the series its own axis on the right.
color, dashStyle, lineWidth, precision How it looks, and the decimal places in its tooltip.

A plot of more than 10 values, or more than 50 plots in a run, stops it. A value that is not a number is skipped with a warning in the log.

function onIntervalClose() {
plot("Moving averages", sma(5), sma(30));
plot("Band", [sma(5), sma(30)]);
plot("Momentum", { name: "RSI", overlay: false, value: rsi(14) });
}