Reconstructing a KDJ-Style Oscillator from a Rolling Price Range
Summary
This document presents a hand-coded version of a KDJ-style indicator intended to match the implementation described by TradingView, after the author observed that TradingView and FMZ produced different values. The calculation first finds the highest high and lowest low over a lookback window, then expresses the close's position within that range as a percentage. It smooths this series with a moving average to produce K, then smooths K again to produce D.
The stated evidence is a comparison in which the hand-coded output reportedly matched TradingView; no test cases or numerical comparisons are included. The snippet returns only the two smoothed series, so it does not show a separate J line or explain how to trade the values. It also does not specify handling for zero-width ranges, initialization, or indexing conventions, which can affect results across platforms. Treat it as an implementation note, not validation of the indicator's predictive value.
Key ideas
- The oscillator starts with the close's location within a rolling high-low range.
- The range position is expressed as a percentage and smoothed to form K.
- A second moving average smooths K to form D.
- The author reports matching TradingView values, but supplies no detailed comparison evidence.
- The calculation's edge-case and initialization behavior is not explained.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.