Skip to main content

plot

plot

Syntax Format

plot(series, name="My Indicator", color=color.yellow, line_width=1, plot_style=style.dash_line)

Overview

The Plot function is essential for your indicator as it allows you to visually represent the calculation part, you can use it for all types of indicators.

The Plot function has many parameters, which is useful for customization purposes.

Parameters

The following parameters of the Plot function are the most common ones, but they are sufficient for the majority of indicators.

ParameterTypePurposeDefault State
seriesseries[numeric]Input series, the data to be shown as a plot-
namestringName of the plot "plot(first,second)"
colorcolorColor of the plot"white"
line_widthintegerWidth of the plot line1
offset integerThe offset in candles to shift the line left or right0
plot_styleplot_stylePlot style. Not yet handled by the enginestyle.solid_line
na_handling_mode na_modeThe mode for handling nan (not a number) data in the input series (see Nan Mode)na_mode.restart

plot_style

Syntax Format

plot(close, "Close Price", color.red, 2, enum.plot_style.line)

Overview

The plot, which you indicate in the script, can have different visual options. For that, you need to specify it in the parameters with the help of the plot_style function enum items.

Parameters

Enum ItemPurpose
style.solid_lineSolid line
style.dash_lineDashed line
style.areaArea plot
style.points Points plot
style.crossesCrosses plot
style.levels Levels plot

na_mode

Syntax Format

plot(price_with_nans, "Price Continued", color.blue, 2, enum.plot_style.line, enum.na_mode.continue)

Overview

The na_mode parameter is used when certain data cannot be retrieved, does not exist within a given timeframe, or the conditions, set in the script, are not met. In this case, you can indicate in the script, whether the plot should continue being drawn or restart from the point of getting needed data, for example, an asset price value after a gap on the chart.

Parameters

Enum ItemPurpose
na_mode.restart The line is not drawn over the areas, where series values are nan
na_mode.continueThe line connects subsequent valid values

You can also use this mode in conditions, where the indicator is built and shown only if a certain condition is met.