Skip to content
TradequixDocsOpen the terminal
OverviewStart here, search, progress
  • Introduction
  • Quickstart
  • How a script runs
  • Types and qualifiers
  • Operators, conditionals and loops
  • Functions and methods
  • Objects and enums
  • Arrays, matrices and maps
  • Strings and colours
  • Time and sessions
  • Bar states
  • Plotting
  • Inputs
  • Technical analysis
  • Drawings and tables
  • Multiple timeframes
  • Strategies
  • Alerts in scripts
  • Repainting
  • The Pine editor
  • Indicator settings
  • Coming from TradingView
  • The data
  • Publish and sell
  • Catalogue and community
  • Your dashboard and earnings
  • Errors and debugging
  • Limits
  • Coverage
  • Built-in catalogue
  • Cookbook
  • Write Pine with AI
  • FAQ
  • Glossary
  • Cheat sheet
  • Function reference
  • Will it run here?
  • Error index

Write

Inputs

Turn hard-coded numbers into settings. Every input.* call becomes a field in the indicator's settings, saved per chart.

View as MarkdownOpen in ClaudeOpen in ChatGPT

An input is a value the person using the script can change without touching code. Each input.* call adds one field to the indicator's settings dialog (the gear in its legend), and the chart re-runs the script with the new value.

RunnableEnvelope
1//@version=62indicator("Envelope", overlay = true)3length = input.int(20, "Length", minval = 1, maxval = 500)4pct = input.float(1.5, "Width %", minval = 0.1, step = 0.1)5src = input.source(close, "Source")6showMid = input.bool(true, "Show basis")7col = input.color(color.new(#8b7cff, 0), "Colour")8basis = ta.sma(src, length)9plot(showMid ? basis : na, "Basis", color = col)10plot(basis * (1 + pct / 100), "Upper", color = col)11plot(basis * (1 - pct / 100), "Lower", color = col)

The input types#

FunctionField in settings
input.intA whole number, with minval, maxval, step
input.floatA decimal number, same options
input.boolA checkbox
input.colorA colour picker
input.sourceA choice of series: close, open, hl2, hlc3, ohlc4…
input.timeframeA timeframe picker, for use with request.security
input.string with options = [...]A dropdown
input.text_areaA multi-line text box

The second argument is the title, which is the label in settings.

A dropdown#

RunnableAverage of your choice
1//@version=62indicator("Average of your choice", overlay = true)3kind = input.string("EMA", "Average", options = ["SMA", "EMA", "WMA", "HMA"])4len = input.int(30, "Length", minval = 2)5avg = switch kind6 "SMA" => ta.sma(close, len)7 "EMA" => ta.ema(close, len)8 "WMA" => ta.wma(close, len)9 => ta.hma(close, len)10plot(avg, kind, color = color.orange, linewidth = 2)

How saved values behave#

Values you set are saved with the indicator on that chart and come back next session. They are matched to inputs by position in the script, not by title. So when you later edit the script:

  • A number now outside a new minval/maxval is clamped into range.
  • A value whose input changed type (say a number that became a checkbox) is dropped, with a warning naming the setting.
  • A saved value whose input no longer exists is dropped, with a warning.
  • Inserting an input above others shifts their positions, so their saved values can land on the wrong field. Add new inputs at the end of the list when a script is already in use.

Tip

Give related inputs the same group = "Bands" and the settings dialog shows them under one heading, in the order you declared them.

PreviousPlottingNext Technical analysis

On this page

  • The input types
  • A dropdown
  • How saved values behave

Use with AI

View as MarkdownOpen in ClaudeOpen in ChatGPT