Indicator Authoring
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 });
Recommended Pattern
- choose the script type and whether it overlays price
- declare user inputs with
input.* - calculate the core series with
ta.* - optionally wrap values with
series(...)if you need cross detection - plot the final values
Inputs Used In The Current Samples
input.integer(...)for lengths and thresholdsinput.float(...)for multipliers and smoothing constantsinput.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