Utilities / Reference
function-default-params
Pine v6 parity: function parameters may declare default values. Defaults are evaluated at call time when the caller omits the slot and can reference earlier parameters. Typed prefixes (`float`, `int`, `string`, `bool`, `color`, `simple`, `series`) are accepted but informational only, and a qualifier may precede a USER type or enum — `simple ParticipationModel model`, `series Pivot p`, `simple Lib.Kind k`, `simple Sess[] all`. At the CALL SITE arguments may be named, exactly as for builtins: positional arguments fill slots left to right, a named argument claims its own slot, and any slot left over takes the parameter's default. Arguments are evaluated in the order they are written, whatever slots they fill — `f(b = array.pop(xs), a = array.pop(xs))` gives b the first value popped. The same applies to `method` calls.
function-default-params(param1, param2 = <default>, [type] param3 = <default>) =>
<body>
name(value, param3 = other) // named at the call site → anyParameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
param = default | any | No | — | Optional parameter with default value. Default is re-evaluated on each call where the slot is missing. |
name = value (at the call site) | any | No | — | Binds to the parameter of that name regardless of position. Unfilled slots fall back to their declared defaults. |
Returns
anyExample
safeDiv(float num, float den, float fallback = 0.0) => den != 0 ? num / den : fallback f(a, b = a * 2) => a + bplot(f(5)) // 15 // Named argument skips the middle slot, which keeps its default.band(series float src, simple int len = 20, simple float mult = 2.0) => ta.sma(src, len) + mult * ta.stdev(src, len)plot(band(close, mult = 3.0))Names and aliases
Guides and navigation are localized. Built-in reference descriptions and code examples are maintained in English.