Docs/Indicator Authoring

Indicator Authoring

How to design indicators that match the current sample set and runtime.

An indicator should answer one question well.

Examples from the current sample set:

  • trend direction
  • trend strength
  • overbought or oversold state
  • volatility expansion or compression
  • volume pressure

Canonical Shape

script({ type: 'indicator', priceStudy: true });

const length = input.integer("Length", 20);
const value = ta.sma(close, length);

plot(value, { type: "line", color: "#D65A31", linewidth: 2 });
  1. choose the script type and whether it overlays price
  2. declare user inputs with input.*
  3. calculate the core series with ta.*
  4. optionally wrap values with series(...) if you need cross detection
  5. plot the final values

Inputs Used In The Current Samples

  • input.integer(...) for lengths and thresholds
  • input.float(...) for multipliers and smoothing constants
  • input.bool(...) for toggles like true-range behavior

Common Indicator Shapes

  • moving average lines
  • oscillator panels
  • upper/middle/lower bands
  • cloud or channel overlays
  • single-point trend markers

Example: Bollinger Style Overlay

script({ type: 'indicator', priceStudy: true });

const length = input.integer("Length", 20);
const mult = input.float("Mult", 2);
const { upper, middle, lower } = ta.bbands(close, length, mult);

plot(upper, { type: "line", color: "#D65A31" });
plot(middle, { type: "line", color: "#1D4E89" });
plot(lower, { type: "line", color: "#3A7D44" });

Practical Rules

  • keep indicator state derived from the bar series
  • expose the fewest inputs needed to make it useful
  • match the visual scale to the indicator type
  • prefer a clear name over a generic label

Next Reading