talib.STOCH
Calculates the Stochastic and returns the slow %K and slow %D.
talib.STOCH(inPriceHLC)
talib.STOCH(inPriceHLC, optInFastK_Period)
talib.STOCH(inPriceHLC, optInFastK_Period, optInSlowK_Period)
talib.STOCH(inPriceHLC, optInFastK_Period, optInSlowK_Period, optInSlowK_MAType)
talib.STOCH(inPriceHLC, optInFastK_Period, optInSlowK_Period, optInSlowK_MAType, optInSlowD_Period)
talib.STOCH(inPriceHLC, optInFastK_Period, optInSlowK_Period, optInSlowK_MAType, optInSlowD_Period, optInSlowD_MAType)Examples
Compute the Stochastic from the latest K-lines.
javascript
function main() {
var records = exchange.GetRecords()
if (!records) return
var ret = talib.STOCH(records)
// Output: [slow %K array, slow %D array]
Log(ret)
}
python
import talib
def main():
records = exchange.GetRecords()
if not records:
return
ret = talib.STOCH(records.High, records.Low, records.Close)
# Output: (slow %K array, slow %D array)
Log(ret)Returns
| Type | Description |
array | Two-dimensional array: [slow %K array, slow %D array] (a tuple in the same order in Python). |
Arguments
| Name | Type | Required | Description |
inPriceHLC |
| Yes | K-line array; the high, low and close fields are used. In Python, pass |
optInFastK_Period | number | No | Fast %K period. Default |
optInSlowK_Period | number | No | Slow %K period. Default |
optInSlowK_MAType | number | No | Moving average type of slow %K; see the MAType table on the |
optInSlowD_Period | number | No | Slow %D period. Default |
optInSlowD_MAType | number | No | Moving average type of slow %D; see the MAType table on the |
See Also
Remarks
TA-Lib equivalent: STOCH(Records[High,Low,Close],Fast-K Period = 5,Slow-K Period = 3,Slow-K MA = 0,Slow-D Period = 3,Slow-D MA = 0) = [Array(outSlowK),Array(outSlowD)].