Stochastic
Stochastic oscillator with %K, smoothed %K and %D lines: where the close sits within the high-low range of the last candles, from 0 to 100.
What you see
Three lines in their own pane, %K, smoothed %K and %D, each with its own color, plus reference lines at 80 and 20. The pane scales to the lowest and highest %K and smoothed %K of the visible candles. With Period Smoothing at 1, smoothed %K equals %K and the two lines lie on top of each other. Green and red lines mark divergences between price and %D.
How it is calculated
%K = 100 × (close − LL) / (HH − LL), where HH and LL are the highest high and lowest low of the lastPeriod %Kcandles, the current one included. If HH equals LL, %K is 0.- Smoothed %K: simple average of %K over
Period Smoothingcandles. %D: simple average of the smoothed %K overPeriod %Dcandles.
Smoothing 1 gives the "fast" stochastic; smoothing 3 gives the "slow" stochastic, whose %K is the fast %D. Divergences compare %D with the close, using Period %K as the swing window and the same rules as the RSI.
How to read it
- %K crossing above %D below 20 is the classic buy signal, %K crossing below %D above 80 the classic sell signal.
- Overbought and oversold readings can last a long time in trends; a trend filter helps.
- Divergences between price and %D hint at a weakening move.
Using it in strategies
Outputs: k, smoothedK, d, and value, which is also %D. In the Trade Setup, "Compare" can check smoothedK against the line d; as a trigger it fires when smoothed %K moves above %D. "Range" or "Against" on d work as overbought/oversold filters. In WickScript, s = stoch(9, 1, 3) gives s.k (the smoothed %K) and s.d, e.g. s.k crosses above s.d. With use indicator "Stoch" with period 14, periodSmooth 3 as st you read st.k, st.smoothedK and st.d.
Settings
Open the settings with the slider icon next to the indicator (Indicators, F3). Numeric settings can be swept as Step 1 / Step 2 parameters when you run a strategy.
Inputs
| Setting | Type | Default | Description |
|---|---|---|---|
| Period %K | Number | 9 | Candles for the high-low range of %K. Also the swing window for divergence detection. (min 1) |
| Period %D | Number | 3 | Candles in the simple average that turns the smoothed %K into %D. (min 1) |
| Period Smoothing | Number | 1 | Candles in the simple average applied to %K (1 = fast stochastic, 3 = slow stochastic). (min 1) |
| Height | Number | 50 | Height of the pane in pixels. (min 10) |
| Look Back Range | Number | 2 | Candles after a swing point that are checked before the swing counts for a divergence. Higher values give fewer, later divergences. (min 1) |
Styles
| Setting | Type | Default | Description |
|---|---|---|---|
| %D Line Color | Color | #26bf8cff | |
| %K Line Color | Color | #6B3AD1ff | |
| %K Smoothing Line Color | Color | #9c7070ff | |
| Line Color overbought | Color | #bd1c1cff | Color of the reference line at 80. |
| Line Color Oversold | Color | #5f38edff | Color of the reference line at 20. |
Outputs
These values can be used in Trade Setup triggers, filters and exits (see Trade Setup) and in WickScript.
| Output | In WickScript | Description |
|---|---|---|
| value | value | %D, the same line as d. |
| k | k | Raw %K. |
| smoothedK | smoothedK | %K after the Period Smoothing average. |
| d | d | %D, the average of the smoothed %K. |
Use in WickScript
use indicator creates this indicator inside a script, with settings by their ID. Each output is a field of the name after as. See WickScript indicators.
wickscript 1
indicator "Stochastic from the list" in pane
use indicator "Stoch" with period 9 as myStoch
show myStoch.value as line "value"