All indicators
Momentum / Own pane

Know Sure Thing

A weighted sum of four smoothed rates of change over rising lookbacks, with a signal line and a zero line.

  • KST
  • Built into Spectral
  • Updates every tick
  • kst
  • know sure thing
  • martin pring
  • rate of change
  • signal line
  • momentum

By Spectral · v1.0.0

MIT-0: free to use, change and share, no attribution needed. What you build from it is yours.

Already in Spectral: add it from the Indicators toolbox. The file here is the same indicator written as a custom indicator, to change or learn from. Installed, it appears next to the built-in one, marked Custom.

Know Sure Thing on a Spectral chart
Spectral chart with sample market data, default settings.

Overview

The Know Sure Thing (Martin Pring) combines four rates of change over 10, 15, 20 and 30 bars. Each is smoothed with a simple average, and the four are added with weights 1, 2, 3 and 4, so the longer cycles count more. The signal line is a 9-bar simple average of KST.

How to read it

Above zero the combined momentum of the four cycles is positive, below zero negative. KST crossing its signal line is the main signal; Pring gave crosses far from zero, after a long run in one direction, the most weight.

Because it blends short and long cycles, KST turns more smoothly than a single rate of change and gives fewer, later crosses. Divergences against price show the cycles losing strength.

Settings and limitations

Defaults are Pring's short-term settings, also TradingView's: rates of change of 10, 15, 20 and 30 bars, smoothed by 10, 10, 10 and 15, with a 9-bar signal. The first value appears on bar ROC length 4 + SMA length 4 (bar 45 with the defaults).

Notes

Matches the KST on TradingView and most platforms. Pring also published longer settings for weekly and monthly charts; set the lengths to use them.

Settings

Each setting appears in the indicator's settings panel in Spectral, next to a color setting for every output.

SettingTypeDefaultRange or optionsWhat it does
ROC length 1Whole number101 – 500Bars in the shortest rate of change, weighted 1.
ROC length 2Whole number151 – 500Bars in the second rate of change, weighted 2.
ROC length 3Whole number201 – 500Bars in the third rate of change, weighted 3.
ROC length 4Whole number301 – 500Bars in the longest rate of change, weighted 4.
SMA length 1Whole number101 – 500Bars in the simple average of the first rate of change.
SMA length 2Whole number101 – 500Bars in the simple average of the second rate of change.
SMA length 3Whole number101 – 500Bars in the simple average of the third rate of change.
SMA length 4Whole number151 – 500Bars in the simple average of the fourth rate of change.
Signal lengthWhole number91 – 500Bars in the simple average of KST that forms the signal line.
SourcePrice sourcecloseopen, high, low, close, hlc3Price the rates of change are calculated from.

What it draws

Lines

  • KSTsolid · 1.5 px · primary#8AA9C3
  • Signalsolid · 1 px#C4A46A

Levels

  • Zero linedotted · 1 px#788493

Source

Save it as kst.js and add it with Indicators → Custom indicators → Add file…. The format is explained in the custom indicators guide.

// Copyright (c) 2026 Spectral
// SPDX-License-Identifier: MIT-0
// Free to use, copy, modify and share: https://spectral.trade/docs/custom-indicators/LICENSE.txt

/** Percent change over `length` bars; null until `length` earlier bars exist or when the earlier price is 0. */
function rateOfChange(values, length) {
  return values.map((value, index) => {
    const earlier = index >= length ? values[index - length] : null;
    return earlier === null || earlier === 0 ? null : (100 * (value - earlier)) / earlier;
  });
}

/** @type {import('./spectral-indicator').IndicatorV2} */
export default {
  schemaVersion: 2,
  id: 'kst',
  name: 'Know Sure Thing',
  shortName: 'KST',
  version: '1.0.0',
  author: 'Spectral',
  description: 'A weighted sum of four smoothed rates of change over rising lookbacks, with a signal line and a zero line.',
  pane: 'oscillator',
  live: { lookback: 'rocLength1 + rocLength2 + rocLength3 + rocLength4' },
  inputs: {
    rocLength1: { type: 'integer', label: 'ROC length 1', default: 10, min: 1, max: 500, description: 'Bars in the shortest rate of change, weighted 1.' },
    rocLength2: { type: 'integer', label: 'ROC length 2', default: 15, min: 1, max: 500, description: 'Bars in the second rate of change, weighted 2.' },
    rocLength3: { type: 'integer', label: 'ROC length 3', default: 20, min: 1, max: 500, description: 'Bars in the third rate of change, weighted 3.' },
    rocLength4: { type: 'integer', label: 'ROC length 4', default: 30, min: 1, max: 500, description: 'Bars in the longest rate of change, weighted 4.' },
    smaLength1: { type: 'integer', label: 'SMA length 1', default: 10, min: 1, max: 500, description: 'Bars in the simple average of the first rate of change.' },
    smaLength2: { type: 'integer', label: 'SMA length 2', default: 10, min: 1, max: 500, description: 'Bars in the simple average of the second rate of change.' },
    smaLength3: { type: 'integer', label: 'SMA length 3', default: 10, min: 1, max: 500, description: 'Bars in the simple average of the third rate of change.' },
    smaLength4: { type: 'integer', label: 'SMA length 4', default: 15, min: 1, max: 500, description: 'Bars in the simple average of the fourth rate of change.' },
    signalLength: { type: 'integer', label: 'Signal length', default: 9, min: 1, max: 500, description: 'Bars in the simple average of KST that forms the signal line.' },
    source: { type: 'source', label: 'Source', default: 'close', description: 'Price the rates of change are calculated from.' },
  },
  plots: {
    kst: { label: 'KST', color: '#8AA9C3', lineWidth: 1.5, primary: true },
    signal: { label: 'Signal', color: '#C4A46A', lineWidth: 1 },
  },
  levels: {
    zero: { label: 'Zero line', color: '#788493', lineStyle: 'dotted' },
  },
  docs: {
    overview: 'The Know Sure Thing (Martin Pring) combines four rates of change over 10, 15, 20 and 30 bars. Each is smoothed with a simple average, and the four are added with weights 1, 2, 3 and 4, so the longer cycles count more. The signal line is a 9-bar simple average of KST.',
    howToRead: 'Above zero the combined momentum of the four cycles is positive, below zero negative. KST crossing its signal line is the main signal; Pring gave crosses far from zero, after a long run in one direction, the most weight.\n\nBecause it blends short and long cycles, KST turns more smoothly than a single rate of change and gives fewer, later crosses. Divergences against price show the cycles losing strength.',
    settings: 'Defaults are Pring\'s short-term settings, also TradingView\'s: rates of change of 10, 15, 20 and 30 bars, smoothed by 10, 10, 10 and 15, with a 9-bar signal. The first value appears on bar ROC length 4 + SMA length 4 (bar 45 with the defaults).',
    notes: 'Matches the KST on TradingView and most platforms. Pring also published longer settings for weekly and monthly charts; set the lengths to use them.',
  },
  calculate(ctx) {
    const { bars, inputs, ta } = ctx;
    const source = ta.source(bars, inputs.source);
    const part = (rocLength, smaLength) => ta.sma(rateOfChange(source, rocLength), smaLength);
    const parts = [
      part(inputs.rocLength1, inputs.smaLength1),
      part(inputs.rocLength2, inputs.smaLength2),
      part(inputs.rocLength3, inputs.smaLength3),
      part(inputs.rocLength4, inputs.smaLength4),
    ];
    const kst = source.map((_, index) => {
      let total = 0;
      for (let weight = 1; weight <= 4; weight += 1) {
        const value = parts[weight - 1][index];
        if (value === null) return null;
        total += weight * value;
      }
      return total;
    });
    return { plots: { kst, signal: ta.sma(kst, inputs.signalLength) }, levels: { zero: 0 } };
  },
};

Adapt it with an LLM

Paste this into your assistant and replace the second-to-last line with the change you want.

Start from this Spectral custom indicator: https://spectral.trade/indicators/kst.js
Format reference: https://spectral.trade/docs/custom-indicators.llm.md
Keep the file format and every rule of the reference; give the result a new id, name, shortName and version, and update docs and input descriptions to match.
Keep its live updates exact and fast (section "Fast live updates" of the reference): carry values from bar to bar only through ctx.ta, and raise live.lookback if the change reads further back; Spectral rejects a file whose live updates differ from a full recalculation or are too slow.
Change I want: <describe the change>
Answer with the complete file in one code block, ready to save as <id>.js.