str
Adds a text input field to your indicator’s Inputs panel. This can be used for free text (like a label or ticker symbol) or for a dropdown list when you provide predefined options. Very flexible for user-driven customization.
Syntax
input.str(title, value, id?, options?, tooltip?, group?, inline?)
Parameters
title
string— Label shown in the Inputs panel.value
string— Default text value, or default selected option ifoptionsare provided.id
string(optional) — Unique key used in code. If omitted, auto-generated fromtitle(lowercased, spaces removed).options
string[](optional) — Turns the field into a dropdown menu with fixed choices. The defaultvaluemust match one of these.tooltip
string(optional) — Help text shown on hover.group
string(optional) — Groups this input under a collapsible section.inline
string(optional) — Aligns multiple inputs in the same row if they share the same key.
Return Value
{ id: string } — The final id assigned to the input.
Example
//@version=1
// This is the setup function.
// Here you can define the input parameters for the indicator.
init = () => {
input.str(
'Custom Label',
'My Strategy',
undefined,
undefined,
'Name displayed on chart',
'General Settings'
);
// Dropdown input for moving average type
input.str(
'MA Type',
'SMA',
undefined,
['SMA', 'EMA', 'WMA'],
'Choose the moving average calculation method',
'Moving Averages',
'ma-row'
);
}
// This is the main function. It is called every time a new candle is received.
// Here you can calculate the indicator values and draw the indicator on the chart.
onTick = (length, _moment, _, ta, inputs) => {
};Result

Tips
Use
optionsto enforce valid choices and make UI clearer.Provide intuitive defaults like
"SMA"or"Long"to save clicks for most users.
Warning
If you supply options, the value must match one of them or the dropdown may not work correctly.
Last updated