> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openstrat.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Stochastic Oscillator (%K and %D)

> Master the calculation and practical techniques of the KD indicator

## Overview

The Stochastic Oscillator is commonly represented by two lines, **%K** and **%D**, and is often called the **KD indicator** in Chinese markets.
Its core idea is:

> Look at where the “current close” sits within the “recent high–low range” to judge bull/bear strength and whether conditions are overbought or oversold.

Simply put:

* The closer the close is to the recent **highest price**, the higher the indicator—bulls are strong;
* The closer the close is to the recent **lowest price**, the lower the indicator—bears dominate.

Therefore, the KD indicator is especially useful for:

* Judging whether price has “risen too much” or “fallen too much” in the short term;
* Helping find buy-low/sell-high points in ranging markets;
* Using “golden/death crosses” to hint at short-term turning signals.

## Stochastic Principles

### %K Calculation

%K is the Stochastic Oscillator’s **raw stochastic value**, measuring the close’s relative position within the recent high–low range.

Common formula (using n periods, e.g., 9):

* Highest high: Hn = the highest price over the last n trading days
* Lowest low: Ln = the lowest price over the last n trading days
* Close: C = the current period’s close

Raw stochastic value (%K):

* %K = (C - Ln) ÷ (Hn - Ln) × 100

Meaning:

* When C is close to Hn, %K approaches 100, indicating price is near recent highs;
* When C is close to Ln, %K approaches 0, indicating price is near recent lows;
* When C is in the middle, %K is around 50, suggesting relative balance.

A simple example:

* Highest high over the last 9 days H9 = 110
* Lowest low over the last 9 days L9 = 90
* Today’s close C = 100

Then:

* %K = (100 - 90) ÷ (110 - 90) × 100 = 50

You can interpret this as: price is roughly in the middle of the last 9 days’ range.

### %D Calculation

%D is a **smoothed average line** of %K, more stable and less “twitchy” than %K.

A common approach is a simple moving average of %K (using 3 periods as an example):

* %D(today) = the average of %K over the last 3 days
* i.e., %D = \[%K(today) + %K(yesterday) + %K(day before)] ÷ 3

Purpose:

* Reduce %K’s short-term sharp swings;
* Make signals smoother and clearer;
* Make “golden/death crosses” more meaningful.

A quick way to remember:

* **%K**: sensitive, fast—like a short-term trader;
* **%D**: smoother, slower—like a steady “trend confirmer.”

### Trading Signals

The three most common KD signals are:

1. Golden and death crosses
2. Overbought and oversold
3. Stronger signals from “high-zone cross / low-zone cross” (location-aware confirmation)

1) Golden Cross (bullish signal)

* Definition: %K crosses upward through %D
* Meaning: short-term momentum strengthens; buying pressure begins to dominate
* Especially noteworthy when a golden cross occurs in a **low zone (e.g., below 20)**

Example:
After a decline and stabilization, KD is around 15 and %K crosses above %D—often treated as one signal of a “short-term bottom and rebound.”

2. Death Cross (bearish signal)

* Definition: %K crosses downward through %D
* Meaning: short-term momentum weakens; selling pressure begins to dominate
* Especially when a death cross occurs in a **high zone (e.g., above 80)**, watch for pullback risk

Example:
After a high-level advance slows, KD is around 85 and %K crosses below %D—often treated as one signal of a “short-term top or correction.”

3. Overbought and oversold

* Common zones:

  * KD > 80: overbought—short-term overheated, possibly exhausting upside momentum;
  * KD \< 20: oversold—short-term overcooled, possible rebound opportunity.
* Note:
  Overbought ≠ must fall, oversold ≠ must rise;
  In strong trends, KD can stay at high or low levels for a long time—this is “stickiness.”

## Core Concepts

When using KD, it helps to understand its nature from these angles:

1. Relative position, not absolute price
   KD doesn’t care whether the price is 10 or 100—it cares about:
   “Within the last n periods’ range, is price near the top, near the bottom, or in the middle?”

2. Oscillator characteristics
   KD swings within 0–100 and is a typical **oscillator**.
   It fits better in **range-bound, oscillating markets**; in trending markets it can become “stuck” at high/low levels.

3. Parameters affect “speed”
   The shorter n is, the more sensitive KD becomes—more signals, more noise;
   The longer n is, the smoother KD becomes, but turning signals may lag.

4. A helper tool, not a “standalone decision maker”
   KD works best when combined with trend indicators (MAs, MACD), support/resistance, volume, etc.
   Making large position decisions solely on KD crosses is risky.

## Practical Application

Below is a simplified case to illustrate KD in practice (for teaching only; not investment advice).

Assume a stock has been ranging between 10 and 12 for the past two months:

* It repeatedly bounces near 10;
* It repeatedly fails near 12;
* This is a classic box-range structure.

1. Using a low-zone golden cross

* When price pulls back to around 10.2, KD has fallen to about 18;
* A few days later, price stops making new lows and prints a small bullish candle; %K crosses above %D below 20, forming a **low-zone golden cross**;
* With price near the range floor and no abnormal volume surge, you might probe a small long;
* Place the stop below 10 (e.g., 9.7). If the range breaks, exit.

2. Using a high-zone death cross

* Price then rebounds toward 11.8–12;
* KD rises above 85 and forms a **death cross** at high levels, while price stalls with volume near resistance;
* Consider scaling out or taking profit, at least avoiding further chasing at that level.

This example shows:

* KD isn’t a “buy/sell switch,”
* It’s a tool that helps you act more disciplined near the “range top” and “range bottom.”

## FAQs

### Q1: Why does KD often give “reversal signals” too early in strong trends?

Because KD’s logic implicitly assumes price oscillates within a range and tends to revert after deviating too far (“mean reversion”).

But in strong trends:

* In uptrends, price keeps making new highs, and KD can stay above 80 for a long time;
* In downtrends, price keeps making new lows, and KD can stay below 20 for a long time.

In other words:
In strong trends, **“overbought can become more overbought, and oversold can become more oversold.”** Golden/death crosses and overbought/oversold signals appear frequently but don’t necessarily mean the trend will reverse immediately.

A better approach:

* First use MAs, trendlines, etc. to determine whether a clear one-way trend exists;
* In strong trends, use KD only in the trend direction (e.g., in an uptrend, focus on low-zone golden crosses after pullbacks) and avoid heavy counter-trend trades based only on “overbought.”

### Q2: Do KD parameters have to be 9, 3, 3?

9, 3, 3 is the most common default, but it’s not the only choice.

General experience:

* Daily charts:

  * 9, 3, 3 or 14, 3, 3 are common;
* Short timeframes (e.g., 5-minute, 15-minute):

  * Noise is higher; you may slightly increase the lookback, e.g., 14, 3, 3, to make it smoother;
* Long timeframes (weekly, monthly):

  * You can keep defaults, mainly to judge longer-term overbought/oversold conditions.

The key isn’t finding “perfect parameters,” but:

* After choosing a set, observe how it behaves on a specific instrument and timeframe over time;
* Learn the “personality” of that setup, rather than constantly changing parameters trying to “fit everything.”

### Q3: Should I act immediately whenever a KD golden/death cross appears?

You shouldn’t mechanically treat it as “golden cross must buy, death cross must sell.”

A more robust approach:

* Treat golden/death crosses as **reminder signals**:

  * Low-zone golden cross: “this may be a phase low—watch closely”
  * High-zone death cross: “this may be a phase high—consider trimming or defending”
* Then make decisions with additional context:

  * Is the market trending or ranging?
  * Is price near key support/resistance?
  * Is volume expanding or contracting?
  * Are there major news or fundamental changes?

Think of KD as a “warning light” system, not an “auto-trading program.”

## Summary

Key takeaways:

1. The essence of KD:

   * It measures bull/bear strength using the close’s relative position within the recent high–low range;
   * %K is fast and %D is slow; their crossings create golden/death cross signals.

2. Main usage:

   * Focus on low-zone golden crosses and high-zone death crosses;
   * Use overbought (`>80`) and oversold (`<20`) zones as references.

3. Best regimes:

   * More effective in ranging/box markets;
   * In strong trends it can become sticky and must be combined with trend tools.

4. Principles:

   * Use KD as a supporting tool, not a single basis for trading decisions;
   * Combine with price structure, support/resistance, volume, and risk management for holistic decisions.

One-sentence summary:

> KD doesn’t “predict the future”—it tells you:
> “Is the current position relatively high, relatively low, or about average?”
> The real decision still comes from your trading system and risk management.

## Further Reading

* *Technical Analysis of the Futures Markets* (John J. Murphy): chapters on Stochastics and oscillators
* Technical analysis texts comparing KD, RSI, and other oscillators, with practical application chapters
