Know Sure Thing (KST) AFL Code

Know Sure Thing also known as KST is a momentum indicator developed by renowned technical analyst Martin Pring. It calculates the weighted sum of 4 different smoothened rate of changes (ROC) on different periods. Highest weight is given to the longest period and the least weight is given to the shortest period

If you are unaware of the rate of change (ROC), it is the percentage difference between the current price and price a certain number of periods ago.

Martin Pring introduced this indicator in 1992 in the stocks and commodities magazine. Since then it’s been widely used by traders across the globe. The indicator also consists of a signal line which is 9 periods simple moving average of the KST line

Preferred Timeframe

It’s recommended to use this indicator in higher timeframes like Daily or Weekly.

Also Read: Triangular Moving Average AFL Code


Below is the screenshot of the know sure thing (KST) indicator plotted in an Amibroker chart. It is plotted as a white line over the candlestick chart.

Along with KST, a signal line is also plotted as a blue line.

Know Sure Thing AFL Screenshot

Know Sure Thing (KST) AFL Download

Download the AFL code of know sure thing (KST) from the below link:

Know Sure Thing AFL Download

AFL Explanation

After plotting the chart title and candlestick chart, KST and KSTSingal are calculated using the below formulas:

KST = (RCMA1 * 1) + (RCMA2 * 2) + (RCMA3 * 3) + (RCMA4 * 4)

KSTSignal = MA(KST,9)


RCMA1 = 10-Period SMA of 10-Period Rate-of-Change

RCMA2 = 10-Period SMA of 15-Period Rate-of-Change

RCMA3 = 10-Period SMA of 20-Period Rate-of-Change

RCMA4 = 15-Period SMA of 30-Period Rate-of-Change

MA = simple moving average

And then, KST and KSTSignal are plotted on a candlestick chart by using the standard Amibroker “plot” function.

Do you want to learn AFL coding from scratch and build your own profitable trading systems? Check out our best-selling Algorithmic trading Bootcamp course bundle.

Long and Short Rules

Here are the long and short rules you can consider while trading through KST:

  1. If KST is rising, it signifies uptrend
  2. If KST is falling, it signifies downtrend
  3. If KST crosses above KSTSignal, go long
  4. If KST crosses below KSTSignal, go short
  5. KST can also be used to assess the technical divergence between price and indicator. For example- if price makes a higher high and KST makes a lower high, then the bullishness may be subsiding. And if price makes a lower low and KST makes a higher low, then the bearishness may come to an end soon


All the AFL’s posted in this section are for learning purposes. Trading Tuitions does not necessarily own these AFL’s and we don’t have any intellectual property rights on them. We might copy useful AFL’s from public forums and post it in this section in a presentable format. The intent is not to copy anybody’s work but to share knowledge. If you find any misleading or non-reproducible content then please inform us at support@tradingtuitions.com

Related Posts

Leave a Reply

Your email address will not be published.