3.4.8Indicators & Oscillators

Learn the stochastic oscillator

2,536 words12 min readdifficulty · medium2 backlinks

What It Is

Key insight: The stochastic doesn't measure absolute price or rate-of-change—it measures relative position. A 100stockatthetopofitsrangehasthesamestochastic(100)asa100 stock at the top of its range has the same stochastic (100) as a 10 stock at the top of its range.


The Formula (Derived)

Step 1: The Raw Stochastic (%K)

Goal: Express "where is Close relative to the Low–High range?" as a percentage.

The range over N periods is:

  • Highest High: HN=max(High1,High2,,HighN)H_N = \max(\text{High}_1, \text{High}_2, \ldots, \text{High}_N)
  • Lowest Low: LN=min(Low1,Low2,,LowN)L_N = \min(\text{Low}_1, \text{Low}_2, \ldots, \text{Low}_N)

Today's close CC sits somewhere between LNL_N and HNH_N. The distance from the low is CLNC - L_N. The total range is HNLNH_N - L_N. The proportion is:

Proportion=CLNHNLN\text{Proportion} = \frac{C - L_N}{H_N - L_N}

Convert to 0–100 scale:

Why this step? We want a normalized0–100 metric that's comparable across assets and time. A raw distance (CLNC - L_N) isn't comparable; dividing by range makes it dimensionless.

Step 2: The Signal Line (%D)

Raw %K is noisy—it jumps around. We smooth it with a moving average:

Why smooth? Reduces whipsaws. %K crossing %D generates cleaner signals than raw %K crossing a threshold.

Full Stochastic Formula

Standard settings: (14, 3, 3)*

  • 14 periods for %K lookback
  • 3-period SMA of %K → %D
  • Some platforms add a second3-period SMA of %D → "Slow %D" (less common)
Figure — Learn the stochastic oscillator

How to Use It

1. Overbought/Oversold Zones

2. Bullish/Bearish Divergence

3. %K/%D Crossovers


Common Mistakes (Steel-Man)


Worked Examples

Example 1: Calculating %K by Hand

Data (last 5 days, N=5): | Day | High | Low | Close | |---|------|-------| | 1 | 52 | 48 | 50 | | 2 | 53 | 49 | 52 | | 3 | 54 | 50 | 51 | | 4 | 55 | 51 | 54 | | 5 | 56 | 52 | 55.5 |

Step 1: Find H5H_5 and L5L_5

H5=max(52,53,54,55,56)=56H_5 = \max(52, 53, 54, 55, 56) = 56

L_5 = \min(48, 49, 50, 51, 52) = 48

Step2:Applyformula(Day5) **Step 2**: Apply formula (Day 5)

%K = \frac{55.5 - 48}{56 - 48} \times 100 = \frac{7.5}{8} \times 100 = 93.75

**Interpretation**: Close is 93.75% of the way from low to high → **strong bullish momentum**. --- ### Example 2: Bearish Divergence Trade **Setup**: - Stock XYZ rallies from $30 to $40 over 3 weeks. - Week 1 peak: Price=$35, %K=88 - Week 3 peak: Price=$40(new high), %K=72 (lower high) **Analysis**: 1. **Price action**: Higher high (+$5) suggests strength. 2. **Stochastic**: %K dropped 16 points → closes are further from the high of the daily range → **buyers losing conviction**. 3. **Signal**: Bearish divergence. Wait for %K to cross below %D. **Day 21**: %K=68, %D=74 → crossover. **Short at $39.50**. **Day 25**: Price drops to $36. Cover for +$3.50/share profit. **Why this worked**: Divergence flaged weakening momentum before price broke. The crossover confirmed the shift. --- ### Example 3: False Signal in Strong Trend **Setup**: - Stock ABC in strong uptrend,20-day MA sloping up steeply. - Day 10: %K hits 85(overbought). - Day 12: %K crosses below %D at 82. Bearish signal? **What happened**: - You short at $50. - Stock dips to $49, then resumes uptrend to $58over 2 weeks. - Loss: $8/share. **Why it failed**: The stochastic gave a "sell" signal, but the **trend was dominant**. Overbought in an uptrend just means the trend is healthy. The brief pullback to %K=82 was a pause, not a reversal. **Fix**: Add a trend filter. Only take bearish stochastic signals when price is below its 50-day MA (downtrend confirmation). In this case, price was above the50-day MA → ignore the stochastic sell. --- ## Advanced: Stochastic vs. RSI | Feature | Stochastic | RSI | |---------|------------|---| | **Measures** | Position in range | Magnitude of price changes | | **Sensitivity** | More volatile (tracks high/low) | Smother (averages gains/losses) | | **Best for** | Range-bound markets, divergence | Trending markets, momentum strength | **When to use which**: - **Stochastic**: When price oscillates in a channel. Overbought/oversold zones work well. - **RSI**: When trend is strong. RSI >70 in uptrend is confirmation, not a sell signal. --- ## Connections - [[Relative-Strength-Index-RSI]: Sister momentum oscillator; compare for confluence. - [[Moving-Average-Convergence-Divergence-MACD]]: Trend-following; combine stochastic (range) + MACD (trend) for full picture. - [[Support-and-Resistance]: Stochastic extremes often align with S/R zones → higher-probability reversals. - [[Divergence-Trading]]: Core strategy for stochastic; see dedicated note for multi-indicator divergence. - [[Bollinger-Bands]]: Price at lower band + stochastic <20 = strong oversold signal. --- >[!mnemonic] CLOSE-TO-HIGH >**C**ompare >**L**ow to >**O**verall >**S**cale, >**E**xpress as >**T**o-100, >**O**scillator >**H**elps >**I**dentify >**G**ood >**H**ighs (overbought) or lows (oversold). --- >[!recall]- Explain to a 12-Year-Old >Imagine you're playing a video game, and your character's health bar goes from 0 to 100. The stochastic is like asking: "Over the last 14 fights, what's the lowest and highest your health got? And right now, where is your health in that range?" > >If you're at 95/100, you're near the top—super strong! If you're at 10/100, you're almost dead—super weak. The stochastic does the same thing for stock prices. If the stock closes near the high of the last 14 days, the stochastic says "90" (strong). If it closes near the low, it says "10" (weak). > >Traders use this to guess: "Is the stock too strong (tired, about to rest)?" or "Is it too weak (beaten down, about to bounce)?" It's like checking if your health bar is so high you might take a break, or so low you're about to heal up. --- ## #flashcards/stock-market What does the stochastic oscillator measure? :: The position of the current close relative to the high-low range over N periods, expressed as a 0–100 percentage. It measures momentum, not price or value. What is the formula for %K in the stochastic oscillator? :: %K = [(Close - Low_N) / (High_N - Low_N)] × 100, where Low_N is the lowest low and High_N is the highest high over N periods (typically 14). What are the standard settings for stochastic oscillator? ::: (14, 3, 3): 14 periods for %K calculation, 3-period SMA of %K to get %D, sometimes another 3-period SMA of %D for slow stochastic. What is %D in the stochastic? ::: The signal line: a 3-period simple moving average of %K. It smooths %K to reduce noise and generate crossover signals. Stochastic above 80 means what? ::: Overbought zone—price is closing near the top of its recent range. Potential reversal or pause, but can persist in strong uptrends. Not an automatic sell signal. What is a bullish stochastic crossover? ::: When %K crosses above %D, especially below 20 (oversold zone). Signals momentum shifting upward, potential buy. What is bearish divergence in stochastic? ::: Price makes a higher high, but %K makes a lower high. Shows weakening momentum despite price advance—forecasts reversal down. Why can stochastic stay overbought for weeks? ::: In strong uptrends, price consistently closes near daily highs, keeping %K >80. This is normal in bull markets, not a sell signal by itself. Stochastic measures momentum or value? ::: Momentum (position in range). A low stochastic does NOT mean the stock is cheap—it means recent closes are near the low of the range. What is the key difference between stochastic and RSI? ::: Stochastic compares close to high-low range (position); RSI compares magnitude of up-moves vs. down-moves (relative strength). Stochastic is more volatile. When is a bearish stochastic signal strongest? :: When %K crosses below %D above 80 (overbought), AND price is below its 50-day MA (downtrend confirmation). Combines momentum shift with trend context. What does %K = 50 mean? ::: Close is exactly in the middle of the N-period high-low range. Neutral momentum—neither bullish nor bearish extreme. --- **Related**: [[RSI-Divergence-Patterns]] · [[MACD-Histogram-Interpretation]] · [[Williams-Percent-R]] · [[Chart-Patterns-Head-and-Shoulders]] ## 🖼️ Concept Map ```mermaid flowchart TD SO[Stochastic Oscillator] Lane[George Lane 1950s] Q[Where is close in recent range] Range[Price Range over N periods] HN[Highest High HN] LN[Lowest Low LN] C[Current Close C] K[%K Fast Line] D[%D Signal Line] Zones[Overbought / Oversold Zones] Lane -->|developed by| SO SO -->|answers| Q Q -->|uses| Range Range -->|max High| HN Range -->|min Low| LN C -->|input to| K HN -->|input to| K LN -->|input to| K K -->|C minus LN over HN minus LN times 100| K K -->|SMA smoothing M=3| D D -->|K crosses D| Zones Zones -->|K over 80 overbought, under 20 oversold| SO ``` ## 🔊 Hinglish (regional understanding) > [!intuition]- Hinglish mein samjho > Stochastic oscillator ek momentum indicator hai jo yeh bata hai ki aj ka closing price last 14 din ke high-low range mein kahaan hai. Maan lo kisi stock ka14-din ka range hai₹100 se ₹120. Agar aj close hua ₹118 pe, toh woh range ke bilkul top ke pas hai—MATLAB strong momentum hai, buyers control mein hain. Agar close hua ₹102 pe, toh woh bottom ke paas hai—weak momentum, sellers havi hain. Stochastic yeh position ko 0 se 100 ke scale pe convert karta hai:100 matlab close exactly high pe, 0 matlab close exactly low pe. > > Formula simple hai: **%K = [(Close - Lowest Low) / (Highest High - Lowest Low)] × 100**. Isko 3-period moving average se smooth karte hain, woh ban jata hai **%D** line. Jab %K upar jake %D ko cross kare (especially oversold zone <20 mein), toh bullish signal hai—"ab price upar jaayegi." Jab %K neeche jaake %D ko cross kare (overbought >80 mein), toh bearish signal—"ab girne wali hai." Lekin dhyaan rakhna: strong uptrend mein stochastic weeks tak80+ pe reh sakta hai, yeh normal hai. Isliye trend ko dekhe bina blindly signal pe trade mat karo. > > Stochastic ka sabse powerful use hai **divergence**: agar price new high bana rahi hai par %K lower high bana raha hai, MATLAB momentum weak ho raha hai—reversal ane wala hai. Yeh early warning signal hai. Tradersisko RSI ya MACD ke saath combine karte hain confirmtion ke liye. Range-bound markets mein (sideways movement) stochastic bahut accurate hota hai; trending markets mein extra caution chahiye. Overall, yeh tool bata hai ki "buyers kitne strong hain RIGHT NOW"—long-term value nahi, short-term momentum. ![[audio/3.4.08-Learn-the-stochastic-oscillator.mp3]]

Test yourself — Indicators & Oscillators

Connections