Appearance
indicator()
Kind: func
Initializes the indicator context. Call once in the init section to configure how the indicator is displayed on the chart.
Calling indicator() is optional. When omitted, all settings use their default values.
Syntax
indicator(options?) → voidArguments
| Name | Type | Description |
|---|---|---|
| options | object | Partial configuration object (see Options) |
Options
| Name | Type | Default | Description |
|---|---|---|---|
| overlay? | bool | true | When true, plots are drawn on the main price chart. When false, a separate pane is used |
| lookback? | number | platform default | Number of historical bars the indicator can access. Must be at least 1 |
Returns
void
Caveats
- Must be called in the
initsection, not insideonTick(). - Should be called at most once per script.
lookbackmust be at least1; otherwise an error is thrown.
Example
javascript
// Overlay indicator — drawn on the main price chart
indicator({overlay: true});
const length = input.double("length", 20);
function onTick() {
spline(ta.sma(close, length), {title: "SMA"});
}javascript
// Separate pane indicator (default behavior)
indicator({overlay: false});
function onTick() {
const rsi = ta.rsi(close, 14);
spline(rsi, {title: "RSI"});
}javascript
// Limit history access to 50 bars
indicator({lookback: 50});
function onTick() {
spline(ta.sma(close, 50), {title: "SMA 50"});
}