Sidechair

format.* constants

Browse the reference

Number formats for indicator() and str.tostring: format.price, format.mintick, format.percent, format.volume and format.inherit.

Try it in the editor

format.* constants go in the format argument of indicator() and strategy(), and in the format argument of str.tostring. format.price shows numbers with the symbol's price precision. format.mintick rounds to the symbol's minimum tick. format.percent adds a percent sign. format.volume shortens large numbers with K, M and B suffixes. format.inherit, the default, takes the format from the chart.

The format is a display setting: it changes how a value is shown on the price scale, status line and in text, not the value the script computes.

Constants

NameValueDescription
format.inheritinheritUse the chart's own format; the default.
format.mintickmintickRound to the symbol's minimum tick.
format.percentpercentShow a percent sign after the number.
format.pricepriceUse the symbol's price precision.
format.volumevolumeShorten large numbers with K, M and B suffixes.

Remarks

  • The precision argument of indicator() sets the number of decimals when the format needs them.

Example

Pine ScriptPercent and volume formatsOpen in editor
//@version=6
indicator("Formats", format = format.percent, precision = 2)
change = (close / close[1] - 1) * 100
plot(change, "Change", change >= 0 ? color.green : color.red, style = plot.style_columns)
if barstate.islast
    label.new(bar_index, change, "Vol " + str.tostring(volume, format.volume) + "\nClose " + str.tostring(close, format.mintick))

See also

Runs on Sidechair