Skip to content
AlertaChartAlertaScript / docs
AlertaScript / alerta.ta.stoch
On this pageSignatureParametersReturnsExample

Momentum / Reference

alerta.ta.stoch

TradingView-compatible spelling: ta.stoch, runs without warnings

Calculates the Stochastic Oscillator. Pine's `ta.stoch(source, high, low, length)` returns ONE series — the raw %K, 100 × (source − lowest low) / (highest high − lowest low) — which scripts smooth themselves, e.g. `k = ta.sma(ta.stoch(close, high, low, 14), 3)`. AlertaScript's own `[k, d] = stoch(close, high, low, 14)` returns the smoothed pair (k_smooth / d_smooth, default 3).

alerta.ta.stoch(close, high, low, length, k_smooth, d_smooth) → [k, d]

Parameters

NameTypeRequiredDefaultDescription
closeseries floatYes—Close price series.
highseries floatYes—High price series.
lowseries floatYes—Low price series.
lengthintYes—Length.
k_smoothintNot specified3Smooth K.
d_smoothintNot specified3Smooth D.

Returns

[k, d]

Example

alerta.ta.stoch
[k, d] = stoch(close, high, low, 14)plot(k, { title: "K", color: color.blue, pane: "oscillator" })plot(d, { title: "D", color: color.orange, pane: "oscillator" })

Names and aliases

Guides and navigation are localized. Built-in reference descriptions and code examples are maintained in English.

AlertaScript

No results found.

Search by name, alias, or keyword.