Ids: what names are kept
How an input or a plot is named for the saved chart. The name is the id, a title is free text, and a renamed item keeps its saved value with was.
When a chart is saved, it stores the value of every setting and the look of every line next to a name for that setting or line. That name is its id. When the script runs again later, the chart finds each saved value by its id. An id that changes by accident silently loses the member's settings, so the rules about ids are strict and simple.
The name is the id#
For an input, the id is the name you declared it with. The title, the text you write with name = "...", is only what the settings panel shows, and it can be any text in any language.
indicator "Ids from names"
edition = 1
display = price
input length: int = 20, name = "Length of the average"
input src: source = close, name = "Price used"
let average = plot(tech.sma(src, length), name = "Average")
plot(close, name = "Close")Here the input ids are length and src; the plot bound to average has the id average, and the plot titled "Close" has the id close, made from its title. If you later change name = "Length of the average" to a text in another language, the saved value of length is still found.
How a plot gets its id#
- If you give it a name with
let, the name is the id:let average = plot(...). - Otherwise
key = "name"sets it:plot(x, key = "upper_band"). (For an input the option isid.) - Otherwise the id is made from the title: "Slow average" becomes
slow_average. - If the title has no Latin letters (a title in Persian, Arabic, Chinese), nothing can be made from it, and the id is taken from the plot's position. That works until you insert a plot above it, which moves every id below. The checker warns:
indicator "A title in Persian"
edition = 1
plot(tech.sma(close, 20), name = "میانگین")Give such a plot a name or a key, and the title can stay in any language:
indicator "A title in Persian, with an id"
edition = 1
plot(tech.sma(close, 20), key = "average", name = "میانگین")The same rules cover level, shade, mark.shape and the other output functions, and alert.when (its id is made from its title).
An id is used once#
Two items with the same id would share one saved value, so the second is refused:
indicator "The same id twice"
edition = 1
input length: int = 20, name = "Length"
input length: int = 30, name = "Other length"
plot(length)Two plots whose titles would give the same id are warned about (W-ID-COLLISION) and the second gets a number added.
Renaming without losing settings#
You can rename an input or a plot. Say what it used to be called with was, and a value saved under the old name is read as the new item's:
indicator "Renamed input"
edition = 1
display = price
input period: int = 20, name = "Period", was = "length"
plot(tech.sma(close, period), name = "Average")was can list several former ids: was = "length old_length". A value saved under the new id always wins.
Titles are free#
A title is text for people. It can be changed, translated or left out, and it can repeat. An item with no title gets a generic label such as Plot 3.
What an unknown option does#
id and was are two of the options an input takes. Any other option name it does not know is an error (E3130), not something ignored, so a misspelled option can never silently do nothing. Inputs lists them.
See also: Inputs, Plots and drawings, Common mistakes.