Adds a price-source dropdown to the script and returns the chosen series, such as close or hl2.
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
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 floatArguments
| Name | Type | Default | Description |
|---|---|---|---|
| defval | open/ | required | Default series: open, high, low, close, hl2, hlc3, ohlc4, hlcc4 or volume. |
| title | const string | na | Name shown in the Settings dialog, the legend and the Data Window. |
| tooltip | const string | na | Text shown in a tooltip beside the input in the Settings dialog. |
| inline | const string | na | Entries sharing the same inline text sit on one row of the Settings dialog. |
| group | const string | na | Heading the input is listed under in the Settings dialog. |
| display | const plot_display | display. | Where the value appears: a display.* constant or a combination of them. |
| active | input bool | true | When false, the input is greyed out and cannot be edited. |
| confirm | const bool | false | When 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
//@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