Skip to Content
API Referenceplot (plot array)

plot (plot array)

plot(plot_type: "line"|"bar"|"label", data: Array<Number>|Array<Boolean>, options: PlotOptions) -> nil

Registers the contents for an array for plotting on the chart. Currently, line & bar charts can be plotted, as well as labels. In the case of labels, an array of booleans must be provided.

The function also takes in options for the plot, allowing to customize e.g. the color, or give the data a specific name to be displayed on the chart legend.

PlotOptions example (all fields are optional):

{ -- can be either 3 or 6 characters hex color code color = "#333", name = "EMA" }
Note

When the strategy is run live, in backtests, or in the optimizer, this function is effectively a no-op, meaning leaving it in your script will not incur any performance penalty.

However, if you are calculating specific arrays for the purposes of plotting, the act of calculating those will still have an impact on performance.

Example:

local long_entry_condition = crossover(rsi(close, 10), rsi(close, 15)) plot("label", long_entry_condition, { color = "#999900", name = "Enter Long" }) local rsi_for_plot = rsi(close, 15) plot("line", rsi_for_plot, { color = "#870012", name = "RSI 15" })