type and keep one instance of it. The
instance holds the values; you read a field with a dot and change it with :=.
type Peak { ... }is declared at the top level, one field per line, before it is used. A field may have a default that is a plain value (a number, a string,true,false, a color constant,naor a built-in variable such asclose).Peak.new(high, bar_index)creates an instance; arguments follow the field order or may be named. A field left out takes its default, ornawhen it has none.staticcreates the instance once, on the first bar, and keeps it from bar to bar. A field changed with:=keeps its new value on the next bar.
The mistake to avoid
An instance is shared, not copied:b = top gives a second name for the same object. Use top.copy() for an independent one.
See Custom types and enums.