Stochastic oscillator
How far the close sits inside the last few bars' high-low range, from 0 at the low to 1 at the high.
The stochastic oscillator measures where the close sits between the lowest low and the highest high of the last k_window bars. %K is that position: 0 when the close is at the window low, 1 when it is at the window high. %D is a simple average of the last d_window %K values, so it moves more slowly. On default settings both lines spread across the full 0 to 1 range, with a median near 0.5.
How to read it
- Both lines sit in their own pane below the price, always between 0 and 1.
- The 0.5 line is the middle of the recent range: %K above it means the close is in the upper half of its window.
- Near 0.8 or 0.2 the close is at the top or bottom of its window (the classic 80 and 20 on a 0 to 100 scale). On defaults %K sits at 0 or 1 on at least 5 percent of bars each, so one touch means little.
- Crosses between %K and %D are the momentum turns to watch, most useful near the 0.2 and 0.8 zones.
What it outputs
- %K
- Where the close sits in the last k_window bars' high-low range, from 0 at the low to 1 at the high. It is the fast line and reaches the ends often.
- %D
- The average of the last d_window %K values. Smoother than %K, and on default settings it stays between about 0.05 and 0.95 for 90 percent of bars.
Settings
- %K window
- How many bars the high-low range looks back over. Raising it widens the range, so %K moves more slowly and hits 0 or 1 less often. Lowering it to around 5 makes %K swing between the ends on small moves.
- %D window
- How many %K values %D averages. Raising it smooths %D and makes it lag %K more, so %D turns later and crosses %K less often. Lowering it toward 2 makes %D track %K almost exactly.
Pitfalls
- Despite the name, the value is not a probability. It is a position inside a rolling range, so a reading of 1 only means the close is at the window high right now.
- In a strong trend %K can stay pinned near 0 or 1 for a long time, so an extreme reading alone is not a reversal.
- The first k_window + d_window - 1 bars (16 on defaults) have no value. A window whose high equals its low leaves a gap in the line rather than a 0 or 1.