Sidechair

input.source()

Browse the reference

Adds a price-source dropdown to the script and returns the chosen series, such as close or hl2.

Try it in the editor

input.source lets the user pick which price series a calculation runs on. defval sets the starting choice, written as a plain name: input.source(close, "Source").

The result is a series, not a number, so it can be passed to ta.* functions and indexed with [1].

Syntax

Pine Script
input.source(defval: open/high/low/close/hl2/hlc3/ohlc4/hlcc4/volume, title: const string (optional), tooltip: const string (optional), inline: const string (optional), group: const string (optional), display: const plot_display (optional), active: input bool (optional), confirm: const bool (optional)) -> series float

Arguments

NameTypeDefaultDescription
defvalopen/high/low/close/hl2/hlc3/ohlc4/hlcc4/volumerequiredDefault series: open, high, low, close, hl2, hlc3, ohlc4, hlcc4 or volume.
titleconst stringnaName shown in the Settings dialog, the legend and the Data Window.
tooltipconst stringnaText shown in a tooltip beside the input in the Settings dialog.
inlineconst stringnaEntries sharing the same inline text sit on one row of the Settings dialog.
groupconst stringnaHeading the input is listed under in the Settings dialog.
displayconst plot_displaydisplay.allWhere the value appears: a display.* constant or a combination of them.
activeinput booltrueWhen false, the input is greyed out and cannot be edited.
confirmconst boolfalseWhen true, the script asks for this value when it is first added to the chart.

Returns

series float: the chosen price series.

Remarks

  • On Sidechair: the choices are the built-in price series open, high, low, close, hl2, hlc3, ohlc4, hlcc4 and volume. The output of another indicator on the chart cannot be selected.
  • On Sidechair: confirm, display and active are accepted and ignored.

Example

Pine ScriptAverage of a chosen sourceOpen in editor
//@version=6
indicator("Source picker", overlay = true)
src = input.source(close, "Source")
plot(ta.sma(src, 20), "SMA", color = color.orange, linewidth = 2)

See also

Runs on Sidechair