Inputs and settings
Anything you declare with input.* appears in the indicator's gear, where you can change it without touching the code.
len = input.int(14, "Length", minval = 1, maxval = 200, group = "Main")
src = input.source(close, "Source")
mode = input.string("EMA", "Type", options = ["EMA", "SMA"])
tf = input.timeframe("D", "Timeframe")
sess = input.session("0800-1600", "Session")
Kinds of input
| Function | Setting shown |
|---|---|
input.int, input.float | A number. minval, maxval and step limit it. |
input.bool | A switch. |
input.string | Text, or a dropdown when you pass options. |
input.color | A colour picker. |
input.source | A choice of price series (close, open, hl2, ...). |
input.timeframe | A timeframe dropdown. |
input.session | A session such as 0800-1600. |
input.enum | A dropdown of an enum's values, shown by their titles. See Enums. |
input(...) | The plain form picks the kind from the default you give. |
Rules
- An input's default must be a fixed value, not something computed from price.
- Saved values are kept per input name, so renaming an input resets it.
groupandtitlemay be a string kept in a variable (G = "Main"), so a group name can be written once.