# src

Creates a **dropdown input** so the user can choose which price source to use (open, high, low, close, or common blends like hl2/hlc3/ohlc4). Perfect for letting users switch the data feeding your calculations without editing code.

### Syntax&#x20;

`input.src(title, value, id?, group?, tooltip?, inline?)`

### Parameters

* `title` *(string)* · Label shown in the inputs panel (e.g., "Price Source").
* `value` *(SourceType)* · Default option: `'open' | 'high' | 'low' | 'close' | 'hl2' | 'hlc3' | 'ohlc4'`.
* `id` *(string)* · Optional unique key for this input (defaults to a simplified version of `title`).
* `group` *(string)* · Optional group name to organize inputs under a collapsible section.
* `tooltip` *(string)* · Optional helper text shown on hover.
* `inline` *(string)* · Optional inline group ID to place inputs on the same row.

### Return Value

*`{ id: string }`* · The unique identifier you’ll use to read the selected value inside `onTick`.

### Example

**What this does:** Adds a “Price Source” dropdown. On each draw cycle, it reads the choice and plots that source as a simple line.

```javascript
//@version=1
init = () => {
// Show the indicator in the main panel
  indicator({ onMainPanel: true, format: 'inherit' });

  // Create a dropdown for the price source
  // Default = 'close', grouped under "Inputs", with a short tooltip.
  input.src(
    "Price Source",
    "close",                // default
    "price_source",         // id (optional but recommended)
    "Inputs",               // group (optional)
    "Choose which price feeds the plot", // tooltip
    "row1"                  // inline group (optional)
  );
};

onTick = (length, _moment, _, ta, inputs) => {

    // Read the user’s selection from inputs using the returned id
    const sel = inputs.price_source; // one of: 'open','high','low','close','hl2','hlc3','ohlc4'

    // Plot style (kept in a single const)
    const style = {
      color: color.blue
      // (plot.line also accepts plottype and id as extra args if needed)
    };

    // Build the plot using the chosen source
    plot.line("Selected Source", sel(0), style.color);
};
```

### Result

<figure><img src="/files/STMgbh417RcU65Q5oegc" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}

#### Tips

* Use **`input.src`** whenever you want your indicator to adapt to **different price feeds** — for example, allow \
  the user to decide if your moving average should run on *close*, *high*, or *HL2* (average of high and low).
* Combine it with other inputs like `length`, `multiplier`, or `offset` to make your logic more **modular and reusable**.
  {% endhint %}

{% hint style="danger" %}

#### Warning

* Some advanced functions (like TA-Lib calls) might expect raw price arrays; make sure you build them \
  using the **selected source** rather than a fixed field.
* If your indicator references **future or historical bars**, ensure your source retrieval (e.g., `high(1)`, `low(2)`) still respects bar indexing based on the selected source.
  {% endhint %}

{% hint style="success" %}

#### Good Practice

* Keep the `id` short and descriptive (e.g., `"price_source"`).
* When you plot or compute indicators, **name outputs by the chosen source** (e.g., `"EMA (" + sel + ")"`) so the legend stays informative.
  {% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://custom-indicators.gitbook.io/custom-indicators-docs/script-inputs/src.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
