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.
Parameter | Type | Purpose | Default State |
---|---|---|---|
series | series[numeric] | Input series, the data to be shown as a plot | - |
name | string | Name of the plot | "plot(first,second)" |
color | color | Color of the plot | "white" |
line_width | integer | Width of the plot line | 1 |
offset | integer | The offset in candles to shift the line left or right | 0 |
plot_style | plot_style | Plot style. Not yet handled by the engine | style.solid_line |
na_handling_mode | na_mode | The 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 Item | Purpose |
---|---|
style.solid_line | Solid line |
style.dash_line | Dashed line |
style.area | Area plot |
style.points | Points plot |
style.crosses | Crosses 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 Item | Purpose |
---|---|
na_mode.restart | The line is not drawn over the areas, where series values are nan |
na_mode.continue | The 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.