ScriptingHow toHow to group and lay out your inputs

How to group and lay out your inputs

Every input takes the same four presentation arguments beyond its value and title.

ArgumentDoes
groupputs the control under a heading of that name
inlineputs controls sharing the key on one row
tooltipattaches help text to the control
confirmasks the reader to confirm the value

All four are const, so none can be built from series data. Give the same group string to several inputs and they sit together; give the same inline key to two inputs and they share a row.

indicator("Grouped inputs", "grp", true)

src = input.source(close, "Source", inline = "calc", group = "Calculation")
length = input.int(20, "Length", 1, 200, 1, "Bars in the average", "calc", "Calculation")

up = input.color(color.green, "Rising", group = "Appearance")
down = input.color(color.red, "Falling", group = "Appearance")

float average = talib.sma(src, length)

plot(average, title = "Average", color = close > close[1] ? up : down)

Why one of those calls is written positionally

step cannot be named. It is a word the grammar reserves for counted loops, so step = 1 is a parse error. In input.int and input.float it sits fifth, so everything up to and including it goes by position.

input.int(const int defval, const string title, const int minval, const int maxval, const int step, const string tooltip, const string inline, const string group, const bool confirm) → input int

That is why the input.int line above passes eight arguments in order: default, title, minimum, maximum, step, tooltip, inline key, group. Every other input function has no step, so name its arguments freely.

If you want a step and no bounds, pass na for the two bounds. Those three are the only input arguments that accept na.

The failure to watch for

Naming step is the commonest cause of a compile failure. If an input line will not parse, check that first.

See Inputs.

Ready to put this into practice?
Try GoCharting Premium
Unlock advanced orderflow, market profile, options desk, and real-time data — everything you just read about, live in your charts.
Upgrade