input reference
User input constructors and input-panel layout markers for setup and live evaluation.
User input constructors and input-panel layout markers for setup and live evaluation.
input.int
input.int(default: int, title: string = "", min: int? = null, max: int? = null, key: string? = null, description: string? = null, sameLine: bool = false, required: bool = false, when: bool = true) -> intAdds a whole-number input to the script settings.
default sets the starting value.
titlelabels the control;keyidentifies it in saved settings.descriptionadds help text.sameLineplaces the control on the same line as the previous control.requiredmarks the control as required.whenhides the control when false.minandmaxlimit the allowed values and help determine how much history calculations need. An out-of-rangedefaultis rejected before the script runs.
Optional settings can be left out. The value stays fixed during each run. Changing it applies the new settings and may recalculate history.
Contracts
default: Accepted range: min to max. Invalid values are rejected.
Example
script "Integer Input"
input len = input.int(20, title: "Length", min: 1, max: 500)
data chart = subscribe(data.ohlcv)
plot ma = plot.line(title: "MA")
on chart.update {
ma.plot(ta.sma(chart.close, len))
}input.float
input.float(default: float, title: string = "", min: float? = null, max: float? = null, key: string? = null, description: string? = null, sameLine: bool = false, required: bool = false, when: bool = true) -> floatAdds a decimal-number input to the script settings.
default sets the starting value. The result is never null.
titlelabels the control;keyidentifies it in saved settings.descriptionadds help text.sameLineplaces the control on the same line as the previous control.requiredmarks the control as required.whenhides the control when false.minandmaxlimit the allowed values. Null leaves that end unrestricted. An out-of-range or non-finitedefaultis rejected before the script runs.
Optional settings can be left out. The value stays fixed during each run. Changing it applies the new settings and may recalculate history.
Contracts
default: Accepted range: min to max. Must be a finite number. Invalid values are rejected.
Example
script "Float Input"
input mult = input.float(2.0, title: "Multiplier", min: 0.0, max: 10.0)
data chart = subscribe(data.ohlcv)
plot stop = plot.line(title: "Stop")
on chart.update {
stop.plot((chart.close ?? 0.0) - mult * (chart.atr(14) ?? 0.0))
}input.bool
input.bool(default: bool, title: string = "", key: string? = null, description: string? = null, sameLine: bool = false, required: bool = false, when: bool = true) -> boolAdds a true-or-false input to the script settings.
default sets the starting value. The result is never null.
titlelabels the control;keyidentifies it in saved settings.descriptionadds help text.sameLineplaces the control on the same line as the previous control.requiredmarks the control as required.whenhides the control when false.
Optional settings can be left out. The value stays fixed during each run. Changing it applies the new settings and may recalculate history.
Example
script "Boolean Input"
input show = input.bool(true)
data chart = subscribe(data.ohlcv)
setup maybeMa = if show plot.line(title: "MA")
on chart.update {
if (maybeMa != null) {
maybeMa.plot(ta.sma(chart.close, 20))
}
}input.color
input.color(default: color, title: string = "", key: string? = null, description: string? = null, sameLine: bool = false, required: bool = false, when: bool = true) -> colorAdds a color picker to the script settings.
default sets the starting color. The result is never null.
titlelabels the control;keyidentifies it in saved settings.descriptionadds help text.sameLineplaces the control on the same line as the previous control.requiredmarks the control as required.whenhides the control when false.
Optional settings can be left out. The value stays fixed during each run. Changing it applies the new settings and may recalculate history.
Example
script "Color Input"
input maColor = input.color(color.blue, title: "MA Color")
data chart = subscribe(data.ohlcv)
plot ma = plot.line(title: "MA")
on chart.update {
ma.plot(ta.sma(chart.close, 20), color: maColor)
}input.timeframe
input.timeframe(default: timeframe = 1h, title: string = "", key: string? = null, description: string? = null, sameLine: bool = false, required: bool = false, when: bool = true) -> timeframeAdds a timeframe picker to the script settings.
default sets the starting timeframe. The result is never null. Invalid
selections are rejected before any handler runs.
titlelabels the control;keyidentifies it in saved settings.descriptionadds help text.sameLineplaces the control on the same line as the previous control.requiredmarks the control as required.whenhides the control when false.
Optional settings can be left out. The value stays fixed during each run. Changing it applies the new settings and may recalculate history.
Example
script "Timeframe Input"
input tf = input.timeframe(1h, title: "HTF")
data chart = subscribe(data.ohlcv)
data higher = subscribe(data.ohlcv, timeframe: tf)
plot htfClose = plot.line(title: "HTF Close")
on chart.update {
htfClose.plot(higher.close)
}input.select
input.select(default: string, title: string = "", options: string[], key: string? = null, description: string? = null, sameLine: bool = false, required: bool = false, when: bool = true) -> stringAdds a dropdown of text options to the script settings.
default sets the starting selection and should be one of the strings in
options. The result is never null.
titlelabels the control;keyidentifies it in saved settings.descriptionadds help text.sameLineplaces the control on the same line as the previous control.requiredmarks the control as required.whenhides the control when false.
Optional settings can be left out. The value stays fixed during each run. Changing it applies the new settings and may recalculate history.
Contracts
default: Must be one ofoptions. Invalid values are rejected.
Example
script "Select Input"
input mode = input.select("fast", title: "Mode", options: ["fast", "slow"])
data chart = subscribe(data.ohlcv)
plot ma = plot.line(title: "MA")
on chart.update {
ma.plot(ta.sma(chart.close, mode == "fast" ? 10 : 30))
}input.exchange
input.exchange(default: string, title: string = "", key: string? = null, description: string? = null, sameLine: bool = false, required: bool = false, filter: string[]? = null, when: bool = true) -> stringAdds a single-exchange picker to the script settings.
default sets the starting exchange ID. The result is never null.
titlelabels the control;keyidentifies it in saved settings.descriptionadds help text.sameLineplaces the control on the same line as the previous control.requiredmarks the control as required.whenhides the control when false.filterlimits the available exchanges. Null allows all exchanges.
Optional settings can be left out. The value stays fixed during each run. Changing it applies the new settings and may recalculate history.
Example
script "Exchange Input"
input ex = input.exchange("binancef", title: "Exchange")
data chart = subscribe(data.ohlcv, exchange: ex)
plot last = plot.line(title: "Last")
on chart.update {
last.plot(chart.close)
}input.exchanges
input.exchanges(default: string[], title: string = "", key: string? = null, description: string? = null, sameLine: bool = false, required: bool = false, minSelected: int? = null, maxSelected: int? = null, filter: string[]? = null, when: bool = true) -> string[]Adds a multiple-exchange picker to the script settings.
default sets the starting list of exchange IDs, in order. The result array
is never null.
titlelabels the control;keyidentifies it in saved settings.descriptionadds help text.sameLineplaces the control on the same line as the previous control.requiredmarks the control as required.whenhides the control when false.filterlimits the available exchanges. Null allows all exchanges.minSelectedandmaxSelectedlimit the number of selections. Values outside their allowed bounds are rejected before the script runs.
Optional settings can be left out. The value stays fixed during each run. Changing it applies the new settings and may recalculate history.
Contracts
minSelected: Accepted range: 0 to MAX_ARRAY_LEN. Invalid values are rejected.maxSelected: Accepted range: 0 to MAX_ARRAY_LEN. Invalid values are rejected.
Example
script "Exchange List Input"
input exchanges = input.exchanges(["binancef", "hyperliquid"],
title: "Exchanges", minSelected: 1, maxSelected: 3)
data chart = subscribe(data.ohlcv)
setup venues = for ex in exchanges {
subscribe(data.ohlcv, exchange: ex)
}
plot last = plot.line(title: "Last")
on chart.update {
last.plot(chart.close)
}input.section
input.section(title: string = "", key: string? = null, description: string? = null, sameLine: bool = false, when: bool = true) -> voidAdds a section heading to the script settings.
title labels the section, key identifies it, and description adds help
text. Optional settings can be left out. sameLine keeps the section on the
same line; when hides it when false. This adds a heading and returns no value.
Example
script "Section Input"
input (
input.section(title: "General")
len = input.int(20, title: "Length", min: 1, max: 500)
)
data chart = subscribe(data.ohlcv)
plot ma = plot.line(title: "MA")
on chart.update {
ma.plot(ta.sma(chart.close, len))
}input.tab
input.tab(title: string = "", key: string? = null) -> voidAdds a tab to the script settings.
title labels the tab and key identifies it. This adds a tab and returns
no value.
Example
script "Tab Input"
input (
input.tab(title: "General")
enabled = input.bool(true, title: "Enabled")
)
data chart = subscribe(data.ohlcv)
plot last = plot.line(title: "Last")
on chart.update {
if enabled { last.plot(chart.close) }
}input.group
input.group(title: string = "", key: string? = null, collapsible: bool = false, collapsed: bool = false, when: bool = true) -> voidGroups controls in the script settings.
title labels the group and key identifies it.
collapsiblelets the user fold the group.collapsedstarts the group folded when true.whenhides the group when false.
This adds a group and returns no value.
Example
script "Group Input"
input (
input.group(title: "Risk", collapsible: true)
risk = input.float(1.0, title: "Risk", min: 0.0, max: 10.0)
)
data chart = subscribe(data.ohlcv)
plot stop = plot.line(title: "Stop")
on chart.update {
stop.plot((chart.close ?? 0.0) - risk)
}