Black Friday 30% off Basic and ProBlack Friday −30%Ends in––d––h––m––sSee the deal

Plots

What the indicator draws for each candle: lines, columns, areas, shapes, candles, numbers, fills and backgrounds.

How to write them

Plots are listed in the plots of @indicator, in the order they stack: the first one sits at the bottom. They are all written plot.type(key, label, …).

  • key is the plot’s entry in the returned dictionary, and the name its settings are saved under: unique within the indicator, in snake_case.
  • label is the plot’s name in the Style tab of the settings. The legend shows only the values, in the plot’s color.
  • The other arguments are the style: color, width, line style, type. They become the settings the user changes.

plot.series

One number per candle. nan leaves a gap.

typeDrawing
"line"A line; it’s the default type
"step"A step line
"columns"Bars as wide as the candle, from base to the value
"histogram"Thin bars, from base to the value
"area"A line with the area fill
"baseline"Line and two-color fills around a level
"circle", "cross"A circle or a cross at the value
Python
plot.series("sma", "SMA", color=color("#2962FF"), width=2)
plot.series("level", "Level", type="step", pattern="dashed")
plot.series("delta", "Delta", type="columns", base=0)

width is the width of the line, of the histogram bars, or the size of circles and crosses. pattern is "solid", "dashed", "dotted" or "dash_dot". Area and baseline are explained in Colors and style.

plot.shape

A shape where the returned series is True: "circle", "square", "cross", "arrow_up", "arrow_down", or "char" with the character char, even an emoji.

Python
plot.shape("up", "Bullish cross", type="arrow_up", location="below",
           color=color("up"), text="Long")
# in the function:
return {"up": ta.crossover(fast, slow)}
  • location is "above" or "below", above the high or below the low of the candle, or "top" or "bottom", on the edges of the pane.
  • size is the size in pixels; without it, it adapts to the candle width.
  • text is a fixed text next to each shape.

plot.ohlc

Candles or bars drawn by the indicator: the function returns (open, high, low, close). With the default colors, Up and Down, it also chooses the color of each candle.

Heikin Ashi
from totaltrade.v1 import indicator, request, plot, ta

@indicator(short="HA", plots=[plot.ohlc("candles", "Heikin Ashi")])
def calculate(bars=request.bars()):
    o, h, l, c = ta.heikinashi(bars.open, bars.high, bars.low, bars.close)
    colors = ["up" if b >= a else "down" for a, b in zip(o, c)]
    return {"candles": ((o, h, l, c), colors)}

type is "candles", with wicks and hollow, or "bars", with hlc and thin.

plot.text

A row of numbers at the bottom of the pane, one below each candle, like the footprint ones. Several rows stack in the order of plots, the first at the top, and each row’s name sits on the scale, at its height. If a number doesn’t fit in its candle, all the numbers in the row are hidden. size is the text size, from 8 to 20 px.

With cell each number has a colored cell. The cell has a single color or, like color, a list of named colors. The entry becomes a tuple: the values, the cell names if there is more than one, and the intensity of each cell, from 0 to 1, which sets its opacity. If color is a list too, its names come right after the values.

A pane with five rows of colored cells
Volume, buys, sells and delta of each candle, with each row’s name on the scale.
Python
plot.text("delta", "Delta", cell=[
    ("buy", "Buys", color("up")),
    ("sell", "Sells", color("down")),
])
# in the function:
sides = ["buy" if d >= 0 else "sell" for d in delta]
strength = [abs(d) / top for d in delta]   # top: the largest delta you want
return {"delta": (delta, sides, strength)}
  • A cell with the name None, or with intensity nan or 0, stays empty. A nan value leaves the cell without a number.
  • On a strong cell the number turns white or black, to be readable on any color.
  • If the pane has only rows, they share its height and the scale shows only their names.

This is how you build a table, like Bar Statistics: only plot.text rows, in their own pane. The rows stay put even when you drag the scale, don’t count towards the drawing limit and, with scale="left", the names sit on the left. Better than drawn rectangles and texts.

plot.fill

A fill between two bounds, upper and lower: plot.series keys, numbers, or "bottom", the bottom of the pane. It has no entry in the dictionary, because it always fills between its bounds.

Python
plot.fill("band", "Background", 70, 30, fill={"color": color("#7E57C2", 10)})
plot.fill("cloud", "Cloud", "fast", "slow", fill={"color": color("#2962FF", 15)})

plot.background

Colors the full height of the pane where the returned series is True, with a transparent color to let the candles show through.

What to return

PlotDictionary entry
plot.seriesA list of numbers
plot.shapeA list of bools
plot.ohlc(open, high, low, close), four lists
plot.textA list of numbers; with cell, a tuple with the cells
plot.fillNothing
plot.backgroundA list of bools

With named colors the entry becomes a pair: the values and the color name of each candle.

Common options

ArgumentWhat it does
display"all" draws it, "none" starts it hidden: in the settings it’s the Visible toggle.
format, precisionAs in @indicator, which they take their value from: for legend, labels and numbers.
show_last_valueThe last value label on the scale; on if you don’t write it.
show_last_value_lineThe last value line up to the right edge.
editable=FalseThe appearance doesn’t show in the settings.

In the Style tab

Animation: a plot’s display changed
Each plot has its own section: the user changes type, color and width.

The type is also a setting: a line can become columns, area or baseline, but not an arrow, which needs True and False instead of numbers.