> For the complete documentation index, see [llms.txt](https://custom-indicators.gitbook.io/custom-indicators-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://custom-indicators.gitbook.io/custom-indicators-docs/script-inputs.md). Agents can also search and read this documentation through its [MCP server](https://custom-indicators.gitbook.io/custom-indicators-docs/~gitbook/mcp).

# Script Inputs

**Inputs** are controls that let users configure parameters of your indicator or strategy.\
For example: a period for a moving average, a color for a line, or a switch to enable/disable a feature.

**Important:**

* All inputs must be declared **only inside** the `init` control block.
* Always start with **`input.`** followed by the method you want to use (e.g., `input.int`, `input.bool`, `input.color`).

## Inputs API <a href="#inputs-api" id="inputs-api"></a>

> **File:** `inputs‑indicator.api.ts`\
> Provides UI controls so users can configure parameters.

<table><thead><tr><th width="105">Method</th><th width="366">Signature (simplified)</th><th width="99">Returns</th><th>Notes</th></tr></thead><tbody><tr><td><a href="https://custom-indicators.gitbook.io/custom-indicators-docs/script-inputs/int.md"><code>int</code></a></td><td><code>int(title, value, id?, min?, max?, step?, tooltip?, group?, inline?)</code></td><td><code>number</code></td><td>Integer input</td></tr><tr><td><a href="https://custom-indicators.gitbook.io/custom-indicators-docs/script-inputs/float.md"><code>float</code></a></td><td><code>float(title, value, id?, min?, max?, step?, tooltip?, group?, inline?)</code></td><td><code>number</code></td><td>Decimal input</td></tr><tr><td><a href="https://custom-indicators.gitbook.io/custom-indicators-docs/script-inputs/bool.md"><code>bool</code></a></td><td><p><code>bool(title, value, id?, tooltip?,</code> </p><p><code>group?, inline?</code></p></td><td><code>boolean</code></td><td>Checkbox</td></tr><tr><td><a href="https://custom-indicators.gitbook.io/custom-indicators-docs/script-inputs/color.md"><code>color</code></a></td><td><code>color(title, value, id?, group?, tooltip?, inline?)</code></td><td><code>string</code></td><td>Color picker</td></tr><tr><td><a href="https://custom-indicators.gitbook.io/custom-indicators-docs/script-inputs/str.md"><code>str</code></a></td><td><code>str(title, value, id?, options?, tooltip?, group?, inline?)</code></td><td><code>string</code></td><td>Single‑line text</td></tr><tr><td><a href="https://custom-indicators.gitbook.io/custom-indicators-docs/script-inputs/session.md"><code>session</code></a></td><td><code>session(title, value, id?, options?, tooltip?, group?, inline?)</code></td><td><code>string</code></td><td>TradingView session</td></tr><tr><td><a href="https://custom-indicators.gitbook.io/custom-indicators-docs/script-inputs/textarea.md"><code>textarea</code></a></td><td><code>textarea(title, value, id?, tooltip?, group?, inline?)</code></td><td><code>string</code></td><td>Multi‑line text</td></tr><tr><td><a href="https://custom-indicators.gitbook.io/custom-indicators-docs/script-inputs/time.md"><code>time</code></a></td><td><code>time(title, value, id?, min, max, tooltip?, group?, inline?)</code></td><td><code>number</code></td><td>Time of day (ms)</td></tr><tr><td><a href="https://custom-indicators.gitbook.io/custom-indicators-docs/script-inputs/src.md"><code>src</code></a></td><td><p><code>src(title,value,id?, group?,tooltip?,</code> <br></p><p><code>inline?)</code></p></td><td><code>number</code></td><td>Source Input</td></tr></tbody></table>

## Example

```javascript
//@version=1
// This is a template for a custom indicator. You can use this as a starting 
// point to create your own custom indicator.

// This is the setup function.
// Here you can define the input parameters for the indicator.
init = () => {
  input.bool('show draws', true, 'show');
  input.bool('extend fvg', true, 'extend');
  input.int(
    'SMA Length',
    14,
    undefined,       // auto id: "smalength"
    1,               // min
    200,             // max
    1,               // step
    'Number of bars used to calculate SMA',
    'Moving Averages',
    'ma-row'
  );
  input.float(
    'ATR Multiplier',
    1.5,
    undefined,         // auto id: "atrmultiplier"
    0.1,               // min
    10,                // max
    0.1,               // step
    'Factor applied to ATR for stop calculation',
    'Risk Management',
    'risk-row'
  );

  // Example: Notes field
  input.textarea(
    'Strategy Notes',
    'Enter your notes here...',
    undefined,
    'Add optional comments or explanations',
    'General Settings'
  );

  // Example: List of symbols
  input.textarea(
    'Watchlist Symbols',
    'AAPL, MSFT, TSLA',
    undefined,
    'Comma-separated list of tickers',
    'Symbols'
  );

  input.time(
    'Session Start',
    930,          // default: 9:30
    undefined,    // auto id: "sessionstart"
    0,            // min (0 = 00:00)
    2359,         // max (2359 = 23:59)
    'Time when trading session begins',
    'Sessions',
    'session-row'
  );

  // Example: Trading session end time
  input.time(
    'Session End',
    1600,         // default: 16:00
    undefined,
    0,
    2359,
    'Time when trading session ends',
    'Sessions',
    'session-row'
  );

  input.session(
    'Trading Session',
    '0930-1600',
    undefined,                      // auto id: "tradingsession"
    ['0930-1600', '0800-1200'],     // dropdown options
    'Choose the active trading hours',
    'Sessions',
    'session-row'
  );
  
    input.color(
      'Line Color',
      color.blue,  // default color
      undefined,
      'Styles',
      'Choose the line color'
    );

  // Example: Pick a custom RGBA color
  input.color(
    'Background',
    { r: 255, g: 200, b: 50, a: 0.5 }, // semi-transparent orange
    undefined,
    'Styles',
    'Background color with transparency'
  );
}

// This is the main function. It is called every time a new candle is received.
// Here you can calculate the indicator values and draw the indicator on the chart.
onTick = (length, _moment, _, ta, inputs) => {

};
```

{% hint style="danger" %}

#### &#x20;Warning

> Declaring inputs outside of `init` or forgetting the `input.` prefix will cause errors and your indicator may fail to load or get a result you don't expect.
> {% endhint %}

{% hint style="success" %}

#### ✅ Good Practice

> Group inputs by category (e.g., calculation parameters, colors, display options) and use descriptive names. This makes it easier for users to understand and adjust the settings.
> {% endhint %}

>
