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 |
| title? | string | not reported | Indicator name reported to the host application (see Declared titles) |
| shortTitle? | string | not reported | Compact name for legends and pane labels (see Declared titles) |
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.
Declared titles
title and shortTitle describe the script for the host application; they do not affect calculation.
Each title is reported to the host only when the script declares it, and the two are independent: an omitted shortTitle is never derived from title, nor the other way round. Declaring neither reports nothing, so the host can tell "not named" from any declared value — including an explicitly declared empty string — and apply its own naming.
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"});
}javascript
// Name the indicator for the host application
indicator({title: "Relative Strength Index", shortTitle: "RSI", overlay: false});
function onTick() {
spline(ta.rsi(close, 14), {title: "RSI"});
}