> ## Documentation Index
> Fetch the complete documentation index at: https://gocharting.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Inputs

> The input functions that make a script's settings editable from the chart, their common arguments, options and steps, time and enum inputs, and what a default may be.

An input is a setting the person using your script can change from the chart without editing the code. You call an input function
once; the platform shows a control for it, and the call returns the value chosen. The value is fixed for a run of the script, so it
can be used where an `input` value is required, such as `hline(price)` and `plot(linewidth=...)`.

| Function | Control for | Returns |
| - | - | - |
| `input.int`, `input.float` | a number; `minval`, `maxval`, `step` or `options` | `input int`, `input float` |
| `input.bool` | a switch | `input bool` |
| `input.string` | text; `options` makes a list | `input string` |
| `input.color` | a color | `input color` |
| `input.source` | one of `open`, `high`, `low`, `close`, `hl2`, `hlc3`, `ohlc4`, `hlcc4` | `series float` |
| `input.price` | a price | `input float` |
| `input.time` | a time, in milliseconds | `input int` |
| `input.session`, `input.timeframe` | a session or timeframe string | `input string` |
| `input.text_area` | a long text | `input string` |
| `input.enum` | a member of your own `enum` | `input` enum |

`input(defval, ...)` picks the kind from the type of `defval` (`bool`, `color`, `int`, `float`, `string`, or a series for a source).

## Common arguments

After `defval`, every input takes `title`, `tooltip` (help text), `inline` (inputs with the same string share one row), `group`
(inputs with the same string sit under one heading), `confirm` and `display`. All are `const`. `defval` is `const` too, except for
`input.source`, and it may not be `na`:

```lipi-invalid theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("No default")
n = input.int(na, "Length")
plot(close)
```

The compiler says: Argument `defval` of `input.int()` cannot be `na`.

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("Moving average", overlay=true)
src = input.source(close, "Source", group="Average")
length = input.int(20, "Length", minval=1, maxval=200, step=5, group="Average", inline="len")
fast = input.bool(true, "Show fast", tooltip="Adds a short average", group="Average")
col = input.color(color.orange, "Color", group="Average", inline="len")
shortAvg = talib.sma(src, 5)
plot(talib.sma(src, length), title="Average", color=col)
plot(fast ? shortAvg : na, title="Fast", color=color.gray)
```

`step` may be named: `input.int(14, "Length", step=5)` works. The compiler does not check that `defval` lies between `minval` and
`maxval`. `input.int` takes only an int default (`5.5` is refused); `input.float` accepts `5`.

`display` takes `display.*` constants, combined with `+`, and only tells the platform where to show the value; the script never
sees it. Its default is `display.none` for `input.bool`, `input.color`, `input.text_area` and `input.time`, and `display.all` for every other input
(`int`, `float`, `string`, `source`, `price`, `session`, `timeframe`, `enum`).

## Options

`options=[...]` turns a number or string input into a list. The default must be one of the options:

```lipi-invalid theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("Not an option")
n = input.int(10, "Length", options=[7, 14, 21])
plot(close)
```

The compiler says: Argument `defval` of `input.int()` value 10 is not in `options` \[7, 14, 21].

## Time

`input.time` takes milliseconds since 1970 (UTC). A default written as `timestamp("2024-01-01")` passes the editor's check and fails
when the script is added to the chart, because `timestamp` is evaluated only when the script runs and is `na` until then:

```lipi-invalid theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("Start date")
start = input.time(timestamp("2024-01-01"), "Start")
plot(time >= start ? close : na)
```

The compiler says (when added to the chart): Argument `defval` of `input.time()` cannot be `na`. Give the number instead, or build the
date from three integer inputs, which are evaluated when the script runs:

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("Since a date")
start = input.time(1704067200000, "Start (ms)")
day = timestamp(input.int(2024, "Year"), input.int(1, "Month"), input.int(1, "Day"))
plot(time >= start ? close : na, title="Since start")
plot(time >= day ? open : na, title="Since day", color=color.orange)
```

## Enum

`input.enum(defval, title, options, ...)` takes a member of an `enum` you declared (see
[Custom types and enums](https://gocharting.com/docs/scripting/language/custom-types.md)); the member's title is the text of the control. `options` lists the
members offered and must contain `defval`.

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("Mode", overlay=true)
enum Mode {
    Fast = "Fast (10)"
    Slow = "Slow (50)"
}
mode = input.enum(Mode.Fast, "Mode")
plot(talib.sma(close, mode == Mode.Fast ? 10 : 50))
```

## input.source accepts names, not expressions

The default of `input.source` must be one of the eight price series above: `input.source(talib.sma(close, 3))` is refused as not a valid source variable.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.