Skip to content

Documentation / @finchart/indicators / kdj

Function: kdj() ​

kdj(source, options?): Kdj

Defined in: indicators/src/factories.ts:2410

KDJ — the seeded stochastic. rsv = ((close/2 − low_n/2) / (high_n/2 − low_n/2)) × 100 over the window — the halves, so that a window spanning more than half the double range cannot overflow the differences (which would collapse the ratio to a wrong finite 0). Wherever every half is still a normal double (magnitudes of 2⁻¹⁰²¹ and up) and the full differences would not overflow, the halves' differences are exactly half the full ones, so the ratio is the same double as (close − low_n) / (high_n − low_n); where the full differences would overflow, the halves are the reading and the full form is not. In the lowest binade and below, halving rounds and the two can differ — a window one ulp wide there may read or, if its halved range rounds to 0, be no reading. Then k = ((smooth − 1) · k[1] + rsv) / smooth and d = ((signal − 1) · d[1] + k) / signal, both starting at 50 and applying the recurrence from the first RSV on (a first RSV of 80 reads K 60, D 53.3); j = 3k − 2d, which runs outside 0–100. The same option words as stochastic, a different number: that one smooths with sma windows, this one with Wilder-style recursions from a seed, so the same k reads differently — the label says which. A window whose high equals its low is the undefined case — null, where the canonical divides by 1 instead; the recursions skip that bar and keep their state. No lookback is declared: the recursions' memory is counted in observations, not bars, and a flat stretch of any length holds the state across it — so a landing recomputes the whole history, as PVT's does.

Parameters ​

source ​

Source<OHLC>

options? ​

KdjOptions = {}

Returns ​

Kdj