@pond-ts/financial API Reference
    Preparing search index...

    Function kst

    • 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:

      term_i        = SMA(ROC(column, roc_i), smooth_i)     ROC in PERCENT
      ${prefix} = 1·term₁ + 2·term₂ + 3·term₃ + 4·term₄
      ${prefix}Signal = SMA(${prefix}, signalPeriod)

      i = 1 2 3 4
      roc_i = 10 15 20 30
      smooth_i = 10 10 10 15
      weight_i = 1 2 3 4

      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.

      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.

      signalPeriod is exposed because it is the one number vendors genuinely differ on and it does not change what the KST line is.

      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.

      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.

      • 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".

      Type Parameters

      • S extends SeriesSchema
      • const Prefix extends string = "kst"

      Parameters

      Returns TimeSeries<
          readonly [
              S[0],
              ValueColumnsForSchema<
                  readonly [
                      S[0],
                      ValueColumnsForSchema<S>,
                      OptionalNumberColumn<`${Prefix}`>,
                  ],
              >,
              OptionalNumberColumn<`${Prefix}Signal`>,
          ],
      >