Stochastic

Calculates the Stochastic indicator.

Accepts the following parameters:

Parameter NameTypeDefault ValueNotes
kPeriodNumber5-
slowingNumber3-

Returns: Series<Number>

Stochastic is a built-in function - you can use it directly. Below is an example implementation:

1 function Stochastic(kPeriod = 5, slowing = 3):
2 sumLow = Sum(close - Lowest(low, kPeriod), slowing)
3 sumHigh = Sum(Highest(high, kPeriod) - Lowest(low, kPeriod), slowing)
4
5 sumLow / sumHigh * 100 if sumHigh != 0 else 100