Momentum OscillatorsPine Script v6

ta.stoch()

Stochastic Oscillator

Stochastic oscillator. It is calculated by a formula: 100 * (source - lowest(low, length)) / (highest(high, length) - lowest(low, length)).

Syntax

Syntax
ta.stoch(source, high, low, length) → series float

Arguments

ParameterTypeDescription
sourceseries int/floatSeries compared to the range (commonly close).
highseries int/floatHigh series for the range calculation.
lowseries int/floatLow series for the range calculation.
lengthseries intLookback length for highest/lowest range.

Returns

Stochastic.

Remarks

None.

Code Examples

Pine Script v6 Example
//@version=6
indicator("ta.stoch")
plot(ta.stoch(close, high, low, 14))

Trading Applications

Identify overbought/oversold market conditions

Generate buy/sell signals with %K/%D crossovers

Detect bullish/bearish divergences

Combine with trend analysis for filtered entries

Related Functions

Frequently Asked Questions

Generate ta.stoch() Code with AI

Skip the manual coding. Use Pineify's AI Coding Agent to generate Pine Script code using ta.stoch() and other built-in functions instantly.