Stochastic
The Stochastic Oscillator is a momentum indicator that compares a security’s closing price to its price range over a specified period. It helps identify overbought and oversold conditions, making it a valuable tool for spotting potential reversals or entry points in trending and ranging markets.
The indicator consists of two lines: %K (the main line) and %D (a moving average of %K). Traders typically look for crossovers between these lines and observe their position relative to key levels — usually 20 (oversold) and 80 (overbought).
How to Use
- Overbought (>80): The market may be due for a correction.
- Oversold (<20): A potential bullish reversal could be approaching.
- Crossovers: A bullish signal may occur when %K crosses above %D; a bearish signal may follow when %K crosses below %D.
The Stochastic Oscillator is most effective when combined with trend-following tools or support/resistance analysis to filter false signals.
Get Stochastic values via API
We provide API access to the Stoch values for all of the most popular assets like stocks, crypto (try one of the popular exchanges like Binance) and forex, on all commonly used timeframes – from the weekly and daily all the way down to one minute intervals. You can also calculate the values on your own data using our manual method.
Customize Stochastic Sensitivity
You can adjust the sensitivity of the Stochastic Oscillator through three optional input parameters available via the API: kPeriod, dPeriod, and kSmooth. The kPeriod controls how many candles are used to calculate the %K line — a shorter period makes the oscillator more reactive to recent price action, while a longer one smooths out short-term volatility. The dPeriod defines the length of the moving average applied to %K, forming the %D signal line, which traders use to identify crossovers and trend signals. Finally, kSmooth applies additional smoothing to the raw %K line before %D is calculated. By customizing these values, you can fine-tune how quickly the Stochastic responds to price changes, allowing you to align it with your preferred timeframe and trading strategy.
Get started with the stoch
Simply make an HTTPS [GET] request or call in your browser:
[GET] https://api.taapi.io/stoch?secret=MY_SECRET&exchange=binance&symbol=BTC/USDT&interval=1h
API response
The stoch endpoint returns a JSON response like this:
{
"valueK": 69.47174519326735,
"valueD": 78.37243409334958
}
Example response from TAAPI.IO when querying stoch endpoint.
API parameters
binance, binancefutures or one of our supported exchanges. For other crypto / stock exchanges, please refer to our Client or Manual integration methods.
BTC/USDT Bitcoin to Tether, or LTC/BTC Litecoin to Bitcoin...
1m, 5m, 15m, 30m, 1h, 2h, 4h, 12h, 1d, 1w. So if you're interested in values on hourly candles, use interval=1h, for daily values use interval=1d, etc.
backtrack parameter removes candles from the data set and calculates the stoch value X amount of candles back. So, if you are fetching the stoch on the hourly and you want to know what the stoch was 5 hours ago, set backtrack=5. The default is 0.
chart parameter accepts one of two values: candles or heikinashi. candles is the default, but if you set this to heikinashi, the indicator values will be calculated using Heikin Ashi candles. Note: Pro & Expert Plans only.
true or false. Defaults to false. By setting to true the API will return a timestamp with every result (real-time and backtracked) to which candle the value corresponds. This is especially helpful when requesting a series of historical values using the results parameter.
1685577600
1731456000 If you only use fromTimestamp, the API will return all results from that time until present.
number or max. Use this parameter to access historical values on the past X candles until the most recent candle. Use max to return all available historical values. Returns an array with the oldest value on top and most recent value returned the last.
Number of periods for the %K line calculation.
Default: 5
Number of periods for the %D (moving average of %K).
Default: 3
Smoothing applied to the raw %K value to reduce noise.
Default: 3
More examples
Let's say you want to know the stoch value on the last closed candle on the 30m timeframe. You are not interest in the real-time value, so you use the backtrack=1 optional parameter to go back 1 candle in history to the last closed candle.
[GET] https://api.taapi.io/stoch?secret=MY_SECRET&exchange=binance&symbol=BTC/USDT&interval=30m&backtrack=1
Get stoch values on each of the past X candles in one call
Let's say you want to know what the stoch daily value was each day for the previous 10 days. You can get this returned by our API easily and efficiently in one call using the results=10 parameter:
[GET] https://api.taapi.io/stoch?secret=MY_SECRET&exchange=binance&symbol=BTC/USDT&interval=1d&results=10
Looking for even more integration examples in different languages like NodeJS, PHP, Python, Curl or Ruby? Continue to [GET] REST - Direct documentation.