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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
close | series float | Yes | — | Close price series. |
high | series float | Yes | — | High price series. |
low | series float | Yes | — | Low price series. |
length | int | Yes | — | Length. |
k_smooth | int | Not specified | 3 | Smooth K. |
d_smooth | int | Not specified | 3 | Smooth 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.