bool

Adds a toggle (true/false) control to your indicator’s Inputs panel. Ideal for on/off features like “Show SMA” or “Use EMA smoothing”. Internally this creates a StudyInputType.Bool entry with your defaults and optional UI metadata like group, tooltip, and inline layout.

Syntax

input.bool(title, value, id?, tooltip?, group?, inline?

Parameters

  • title string — The label shown in the Inputs panel.

  • value boolean — Default state of the toggle (checked = true, unchecked = false).

  • id string (optional) — Unique key used in your script. If omitted, it’s auto‑generated from title by lowercasing and removing spaces (e.g., "Show SMA""showsma").

  • group string (optional) — Groups this input under a collapsible section with the same name.

  • tooltip string (optional) — Small help text shown on hover in the UI.

  • inline string (optional) — Hint for placing multiple inputs on the same line (use the same token across inputs you want inline).

Return Value

{ id: string } — The final id assigned to this input (useful if you didn’t pass one).

Example

//@version=1

// This is the setup function.
// Here you can define the input parameters for the indicator.
init = () => {
  // Assume `input` is your Inputs helper instance
  input.bool(
    'Show SMA',
    true,
    undefined,           // let it auto-generate "showsma"
    'Moving Averages',   // group
    'Toggle simple moving average visibility',
    'ma-row'             // inline key to align with related inputs
  );
}

// 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) => {

};

Result

Tips

  • You can align a few related toggles on one row by giving them the same inline value (e.g., "ma-row").

  • Use short, action‑oriented titles like “Show SMA”, “Use VWAP bands”, or “Enable alerts” so users instantly know what the toggle does.

Warning

Good Practice

Last updated