Know Sure Thing (Martin Pring) — four smoothed rates of change at four
horizons, added together with the slower ones weighted more heavily, plus a
simple-average signal line:
i =1234 roc_i =10152030 smooth_i =10101015 weight_i =1234
Appends two columns. The point of the construction is that a single rate of
change reads one cycle length; summing four of them, each smoothed and the
longest weighted heaviest, gives a momentum line dominated by the primary
trend but still able to turn early. It is read on zero crossings and on
crosses of its own signal.
The line is named ${prefix}, not ${prefix}Line — the trix
shape: "the KST" is the line, and the signal keeps the family suffix.
The twelve numbers are the study — there are no period options
column, prefix and signalPeriod are the whole option list. The four
look-backs, the four smoothings and the four weights are not exposed,
and that is a decision rather than an omission: Pring published several
KSTs — a short-term daily set, this intermediate daily one, a weekly and a
monthly — and they are different indicators with different readings, not
one indicator with parameters. Arrays of periods on this function would
make kst() name all of them at once, so a chart legend reading "KST"
would mean nothing without the call site beside it.
A caller who wants one of the others composes it from shipped primitives —
percentChange at each look-back, sma over each, then the weighted sum —
which is four lines of arithmetic and is honest about not being this study.
Pring's Special K (the extended, more-terms version listed separately
in the corpus) is likewise its own study, not a mode here.
signalPeriodis exposed because it is the one number vendors genuinely
differ on and it does not change what the KST line is.
Definition, verified
No TA-Lib function, so the oracle is a pandas replication built on the
same pct_change that the TA-Lib-verified percentChange case uses,
with the analytic first-valid bar asserted and two discriminating
separations measured — from an equal-weight sum (80.6 apart on the
oracle input) and from a sum of unsmoothed rates of change (68.5
apart), on a line that spans −56.9…125.4.
The rates of change are percent ((x/x[−n] − 1)·100), matching
percentChange and TA-Lib's ROC; a ratio form (x/x[−n]·100,
TA-Lib's ROCP-vs-ROCR distinction) would shift each term by a constant
100 and therefore the whole line by 1000, which is why it is named here.
Warm-up
The four terms warm up at roc_i + smooth_i − 1 (bars 19, 24, 29 and
44 at the defaults), and the sum is defined only where all four are, so
${prefix} starts at bar 44 — the fourth term's, with no branch in the
code: a missing term is NaN and survives the addition. The signal then
starts signalPeriod − 1 bars later, at 52. Each column is emitted
where it is defined rather than both waiting for the slower.
Both smoothings go through the raw-array kernel (rollingMeanValues),
which waits for smooth_i finite values rather than rows — the rule for
a derived input, and the same reason stochastic's slow %K is not
one bar early.
Edges
Scale-invariant: every term is a ratio, so multiplying every price by
a positive constant leaves both columns unchanged. It is not
shift-invariant — adding a constant changes each ratio. Both pinned as
property tests.
A zero look-back base → undefined for that term, and the sum with
it, inherited from percentChangeValues rather than restated.
Unreachable on prices; reachable when column is a study output that
crosses zero.
An interior gap blanks the bar, the four bars that read it as a
look-back base, and every smoothing window holding one of those — then
recovers. No recursion is involved, so nothing propagates to the end.
Unbounded, in percent-times-weight units; the sum of the weights is
10, so a KST of 30 is roughly "the four horizons averaged 3% each".
Know Sure Thing (Martin Pring) — four smoothed rates of change at four horizons, added together with the slower ones weighted more heavily, plus a simple-average signal line:
Appends two columns. The point of the construction is that a single rate of change reads one cycle length; summing four of them, each smoothed and the longest weighted heaviest, gives a momentum line dominated by the primary trend but still able to turn early. It is read on zero crossings and on crosses of its own signal.
The line is named
${prefix}, not${prefix}Line— the trix shape: "the KST" is the line, and the signal keeps the family suffix.The twelve numbers are the study — there are no period options
column,prefixandsignalPeriodare the whole option list. The four look-backs, the four smoothings and the four weights are not exposed, and that is a decision rather than an omission: Pring published several KSTs — a short-term daily set, this intermediate daily one, a weekly and a monthly — and they are different indicators with different readings, not one indicator with parameters. Arrays of periods on this function would makekst()name all of them at once, so a chart legend reading "KST" would mean nothing without the call site beside it.A caller who wants one of the others composes it from shipped primitives —
percentChangeat each look-back,smaover each, then the weighted sum — which is four lines of arithmetic and is honest about not being this study. Pring's Special K (the extended, more-terms version listed separately in the corpus) is likewise its own study, not a mode here.signalPeriodis exposed because it is the one number vendors genuinely differ on and it does not change what the KST line is.Definition, verified
No TA-Lib function, so the oracle is a pandas replication built on the same
pct_changethat the TA-Lib-verified percentChange case uses, with the analytic first-valid bar asserted and two discriminating separations measured — from an equal-weight sum (80.6 apart on the oracle input) and from a sum of unsmoothed rates of change (68.5 apart), on a line that spans −56.9…125.4.The rates of change are percent (
(x/x[−n] − 1)·100), matching percentChange and TA-Lib'sROC; a ratio form (x/x[−n]·100, TA-Lib'sROCP-vs-ROCRdistinction) would shift each term by a constant 100 and therefore the whole line by 1000, which is why it is named here.Warm-up
The four terms warm up at
roc_i + smooth_i − 1(bars 19, 24, 29 and 44 at the defaults), and the sum is defined only where all four are, so${prefix}starts at bar 44 — the fourth term's, with no branch in the code: a missing term isNaNand survives the addition. The signal then startssignalPeriod − 1bars later, at 52. Each column is emitted where it is defined rather than both waiting for the slower.Both smoothings go through the raw-array kernel (rollingMeanValues), which waits for
smooth_ifinite values rather than rows — the rule for a derived input, and the same reason stochastic's slow%Kis not one bar early.Edges
undefinedfor that term, and the sum with it, inherited from percentChangeValues rather than restated. Unreachable on prices; reachable whencolumnis a study output that crosses zero.